git.iko.soy/typeable/pandoc
on master help sign in
JATS reader: handle "label" element in section title.

Closes #6288.

commit71c4857464c82f5c9c527d99de43061cda22ef48 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 15 Apr 2020, 09:23 (7 years ago) parent20c1c29
2 files changed+15−1
src/Text/Pandoc/Readers/JATS.hs+7−1 test/command/6288.md+8
src/Text/Pandoc/Readers/JATS.hs+7−1
@@ -176,6 +176,7 @@ parseBlock (Elem e) =
176176 "article-meta" -> parseMetadata e
177177 "custom-meta" -> parseMetadata e
178178 "title" -> return mempty -- processed by header
179+ "label" -> return mempty -- processed by header
179180 "table" -> parseTable
180181 "fig" -> parseFigure
181182 "fig-group" -> divWith (attrValue "id" e, ["fig-group"], [])
@@ -289,10 +290,15 @@ parseBlock (Elem e) =
289290 parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry
290291 sect n = do isbook <- gets jatsBook
291292 let n' = if isbook || n == 0 then n + 1 else n
293+ labelText <- case filterChild (named "label") e of
294+ Just t -> (<> ("." <> space)) <$>
295+ getInlines t
296+ Nothing -> return mempty
292297 headerText <- case filterChild (named "title") e `mplus`
293298 (filterChild (named "info") e >>=
294299 filterChild (named "title")) of
295− Just t -> getInlines t
300+ Just t -> (labelText <>) <$>
301+ getInlines t
296302 Nothing -> return mempty
297303 oldN <- gets jatsSectionLevel
298304 modify $ \st -> st{ jatsSectionLevel = n }
test/command/6288.mdnew file+8
@@ -0,0 +1,8 @@
1+```
2+% pandoc -f jats -t native
3+<sec>
4+<label>I</label><title>Introduction</title>
5+</sec>
6+^D
7+[Header 1 ("",[],[]) [Str "I.",Space,Str "Introduction"]]
8+```