diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-04-15 09:23:04 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-04-15 09:23:04 -0700 |
commit | 71c4857464c82f5c9c527d99de43061cda22ef48 (patch) | |
tree | 8e0037e7302a22b3cdf6e9e253c269e0143f448b | |
parent | 20c1c297b295e5da4433e6fe59d03ef8ac109337 (diff) | |
download | pandoc-71c4857464c82f5c9c527d99de43061cda22ef48.tar.gz |
JATS reader: handle "label" element in section title.
Closes #6288.
-rw-r--r-- | src/Text/Pandoc/Readers/JATS.hs | 8 | ||||
-rw-r--r-- | test/command/6288.md | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs index 597e798ab..3672b05f6 100644 --- a/src/Text/Pandoc/Readers/JATS.hs +++ b/src/Text/Pandoc/Readers/JATS.hs @@ -176,6 +176,7 @@ parseBlock (Elem e) = "article-meta" -> parseMetadata e "custom-meta" -> parseMetadata e "title" -> return mempty -- processed by header + "label" -> return mempty -- processed by header "table" -> parseTable "fig" -> parseFigure "fig-group" -> divWith (attrValue "id" e, ["fig-group"], []) @@ -289,10 +290,15 @@ parseBlock (Elem e) = parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry sect n = do isbook <- gets jatsBook let n' = if isbook || n == 0 then n + 1 else n + labelText <- case filterChild (named "label") e of + Just t -> (<> ("." <> space)) <$> + getInlines t + Nothing -> return mempty headerText <- case filterChild (named "title") e `mplus` (filterChild (named "info") e >>= filterChild (named "title")) of - Just t -> getInlines t + Just t -> (labelText <>) <$> + getInlines t Nothing -> return mempty oldN <- gets jatsSectionLevel modify $ \st -> st{ jatsSectionLevel = n } diff --git a/test/command/6288.md b/test/command/6288.md new file mode 100644 index 000000000..29aff0fb9 --- /dev/null +++ b/test/command/6288.md @@ -0,0 +1,8 @@ +``` +% pandoc -f jats -t native +<sec> +<label>I</label><title>Introduction</title> +</sec> +^D +[Header 1 ("",[],[]) [Str "I.",Space,Str "Introduction"]] +``` |