From 9dd2eefded7879df85150484c0476410dd77a4f7 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 4 May 2019 08:45:43 -0700 Subject: JATS writer: fix citations with PMID so they validate. Closes #5481. This includes an update to data/jats.csl. --- src/Text/Pandoc/Writers/JATS.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index 6cbe35bdc..e2c4e1e72 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -18,7 +18,7 @@ import Prelude import Control.Monad.Reader import Data.Char (toLower) import Data.Generics (everywhere, mkT) -import Data.List (isSuffixOf, partition) +import Data.List (isSuffixOf, partition, isPrefixOf) import Data.Maybe (fromMaybe) import Data.Text (Text) import Text.Pandoc.Class (PandocMonad, report) @@ -322,11 +322,15 @@ inlinesToJATS :: PandocMonad m => WriterOptions -> [Inline] -> JATS m Doc inlinesToJATS opts lst = hcat <$> mapM (inlineToJATS opts) (fixCitations lst) where fixCitations [] = [] - fixCitations (x@(RawInline (Format "jats") "") : xs) = - let isRawInline (RawInline{}) = True - isRawInline _ = False - (ys,zs) = break isRawInline xs - in x : Str (stringify ys) : fixCitations zs + fixCitations (x:xs) | needsFixing x = + x : Str (stringify ys) : fixCitations zs + where + needsFixing (RawInline (Format "jats") z) = + "