From 3217bc192ec90f251ad54c098e5ada35f9aa863a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 31 Mar 2017 11:07:09 +0200 Subject: JATS writer: put references in ``. Modified template to include a `` and `` section. This should give authors more flexibility, e.g. to put acknowledgements metadata in ``. References are automatically extracted and put into ``. --- src/Text/Pandoc/Writers/JATS.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index 71a45bf77..aca7dc969 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -34,7 +34,7 @@ module Text.Pandoc.Writers.JATS ( writeJATS ) where import Control.Monad.Reader import Data.Char (toLower) import Data.Generics (everywhere, mkT) -import Data.List (intercalate, isSuffixOf) +import Data.List (intercalate, isSuffixOf, partition) import Data.Maybe (fromMaybe) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class (PandocMonad, report) @@ -88,7 +88,11 @@ writeJATS opts d = -- | Convert Pandoc document to string in JATS format. docToJATS :: PandocMonad m => WriterOptions -> Pandoc -> DB m String docToJATS opts (Pandoc meta blocks) = do - let elements = hierarchicalize blocks + let isBackBlock (Div ("refs",_,_) _) = True + isBackBlock _ = False + let (backblocks, bodyblocks) = partition isBackBlock blocks + let elements = hierarchicalize bodyblocks + let backElements = hierarchicalize backblocks let colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing @@ -112,9 +116,12 @@ docToJATS opts (Pandoc meta blocks) = do hierarchicalize)) (fmap (render colwidth) . inlinesToJATS opts') meta' - main <- (render' . inTagsIndented "body" . vcat) <$> + main <- (render' . vcat) <$> (mapM (elementToJATS opts' startLvl) elements) + back <- (render' . vcat) <$> + (mapM (elementToJATS opts' startLvl) backElements) let context = defField "body" main + $ defField "back" back $ defField "mathml" (case writerHTMLMathMethod opts of MathML -> True _ -> False) -- cgit v1.2.3