diff options
| -rw-r--r-- | src/Text/Pandoc/Writers/JATS.hs | 12 | ||||
| -rw-r--r-- | test/command/7016.md | 1 | ||||
| -rw-r--r-- | test/command/9017.md | 53 |
3 files changed, 65 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index ad18d6cf7..2492a0649 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -91,6 +91,15 @@ writeJats tagSet opts d = do runReaderT (evalStateT (docToJATS opts d) initialState) environment +-- see #9017 for motivation +ensureReferenceHeader :: [Block] -> [Block] +ensureReferenceHeader [] = [] +ensureReferenceHeader (h@(Header{}):refs@(Div ("refs",_,_) _) : xs) = + h:refs:xs +ensureReferenceHeader (refs@(Div ("refs",_,_) _) : xs) = + Header 1 nullAttr mempty : refs : xs +ensureReferenceHeader (x:xs) = x :ensureReferenceHeader xs + -- | Convert Pandoc document to string in JATS format. docToJATS :: PandocMonad m => WriterOptions -> Pandoc -> JATS m Text docToJATS opts (Pandoc meta blocks') = do @@ -100,7 +109,8 @@ docToJATS opts (Pandoc meta blocks') = do TopLevelChapter -> 0 TopLevelSection -> 1 TopLevelDefault -> 1 - let blocks = makeSections (writerNumberSections opts) (Just startLvl) blocks' + let blocks = makeSections (writerNumberSections opts) (Just startLvl) + $ ensureReferenceHeader blocks' let splitBackBlocks b@(Div ("refs",_,_) _) (fs, bs) = (fs, b:bs) splitBackBlocks (Div (ident,("section":_),_) [ Header lev (_,hcls,hkvs) hils diff --git a/test/command/7016.md b/test/command/7016.md index f43fdd21f..4b1e3ea2b 100644 --- a/test/command/7016.md +++ b/test/command/7016.md @@ -39,6 +39,7 @@ Blah [@doe]. </body> <back> <ref-list> + <title></title> <ref id="ref-doe"> <mixed-citation>Doe, J. (2021). Another article. <italic>Proceedings of the Academy of Test Inputs</italic>. diff --git a/test/command/9017.md b/test/command/9017.md new file mode 100644 index 000000000..dd4fd6c51 --- /dev/null +++ b/test/command/9017.md @@ -0,0 +1,53 @@ +``` +% pandoc -t jats --citeproc -s +--- +references: +- author: DeGroot + id: degroot_probability + title: Probability + issued: 2002 +title: Doc example with single reference +--- + +# I like + +[@degroot_probability]. +^D +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.2 20190208//EN" + "JATS-archivearticle1.dtd"> +<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.2" article-type="other"> +<front> +<journal-meta> +<journal-id></journal-id> +<journal-title-group> +</journal-title-group> +<issn></issn> +<publisher> +<publisher-name></publisher-name> +</publisher> +</journal-meta> +<article-meta> +<title-group> +<article-title>Doc example with single reference</article-title> +</title-group> +<permissions> +</permissions> +</article-meta> +</front> +<body> +<sec id="i-like"> + <title>I like</title> + <p>(DeGroot 2002).</p> +</sec> +</body> +<back> +<ref-list> + <title></title> + <ref id="ref-degroot_probability"> + <mixed-citation>DeGroot. 2002. “Probability.”</mixed-citation> + </ref> +</ref-list> +</back> +</article> +``` |
