aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-31 11:07:09 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-31 11:07:09 +0200
commit3217bc192ec90f251ad54c098e5ada35f9aa863a (patch)
tree34ac8633f69cecf401b921425e73c0d0e3b5f330 /src
parent136a53edc88513d0d300a50b9f77ff003baa512f (diff)
downloadpandoc-3217bc192ec90f251ad54c098e5ada35f9aa863a.tar.gz
JATS writer: put references in `<back>`.
Modified template to include a `<back>` and `<body>` section. This should give authors more flexibility, e.g. to put acknowledgements metadata in `<back>`. References are automatically extracted and put into `<back>`.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/JATS.hs13
1 files changed, 10 insertions, 3 deletions
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)