git.iko.soy/typeable/pandoc
on master help sign in
JATS reader: handle "label" element in section title.
71c4857John MacFarlane
src/Text/Pandoc/Readers/JATS.hs+7−1
@@ -176,6 +176,7 @@ parseBlock (Elem e) =
176 "article-meta" -> parseMetadata e
176 "article-meta" -> parseMetadata e
177 "custom-meta" -> parseMetadata e
177 "custom-meta" -> parseMetadata e
178 "title" -> return mempty -- processed by header
178 "title" -> return mempty -- processed by header
179+ "label" -> return mempty -- processed by header
179 "table" -> parseTable
180 "table" -> parseTable
180 "fig" -> parseFigure
181 "fig" -> parseFigure
181 "fig-group" -> divWith (attrValue "id" e, ["fig-group"], [])
182 "fig-group" -> divWith (attrValue "id" e, ["fig-group"], [])
@@ -289,10 +290,15 @@ parseBlock (Elem e) =
289 parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry
290 parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry
290 sect n = do isbook <- gets jatsBook
291 sect n = do isbook <- gets jatsBook
291 let n' = if isbook || n == 0 then n + 1 else n
292 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
292 headerText <- case filterChild (named "title") e `mplus`
297 headerText <- case filterChild (named "title") e `mplus`
293 (filterChild (named "info") e >>=
298 (filterChild (named "info") e >>=
294 filterChild (named "title")) of
299 filterChild (named "title")) of
300+ Just t -> (labelText <>) <$>
295− Just t -> getInlines t
301+ getInlines t
296 Nothing -> return mempty
302 Nothing -> return mempty
297 oldN <- gets jatsSectionLevel
303 oldN <- gets jatsSectionLevel
298 modify $ \st -> st{ jatsSectionLevel = n }
304 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+```