summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-06-07 13:18:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-06-07 13:18:20 -0700
commit4f440583a82d1090dbe212afe77eace8deb0531f (patch)
tree81d29ef85f09ea7f66d62aabfa9c58d817a408fb /src/Text
parent0166aecaab1dfe050ea9ec780833a892c54060e9 (diff)
JATS writer: include title in ref-list.
Previously the reference title ended up in a separate section at the back of the body instead of in the ref-list in the back matter. Closes #8364.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/JATS.hs23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs
index 707c7bad7..c0d91079b 100644
--- a/src/Text/Pandoc/Writers/JATS.hs
+++ b/src/Text/Pandoc/Writers/JATS.hs
@@ -26,7 +26,6 @@ import Control.Monad
import Control.Monad.Reader
import Control.Monad.State
import Data.Generics (everywhere, mkT)
-import Data.List (partition)
import qualified Data.Map as M
import Data.Maybe (fromMaybe, listToMaybe)
import Data.Time (toGregorian, Day, parseTimeM, defaultTimeLocale, formatTime)
@@ -94,27 +93,33 @@ writeJats tagSet opts d = do
-- | Convert Pandoc document to string in JATS format.
docToJATS :: PandocMonad m => WriterOptions -> Pandoc -> JATS m Text
-docToJATS opts (Pandoc meta blocks) = do
- let isBackBlock (Div ("refs",_,_) _) = True
- isBackBlock _ = False
- let (backblocks, bodyblocks) = partition isBackBlock blocks
+docToJATS opts (Pandoc meta blocks') = do
-- The numbering here follows LaTeX's internal numbering
let startLvl = case writerTopLevelDivision opts of
TopLevelPart -> -1
TopLevelChapter -> 0
TopLevelSection -> 1
TopLevelDefault -> 1
- let fromBlocks = blocksToJATS opts . makeSections False (Just startLvl)
+ let blocks = makeSections False (Just startLvl) blocks'
+ let splitBackBlocks b@(Div ("refs",_,_) _) (fs, bs) = (fs, b:bs)
+ splitBackBlocks (Div (ident,("section":_),_)
+ [ Header lev (_,hcls,hkvs) hils
+ , (Div rattrs@("refs",_,_) rs)
+ ]) (fs, bs)
+ = (fs, Div rattrs
+ (Header lev (ident,hcls,hkvs) hils : rs) : bs)
+ splitBackBlocks b (fs, bs) = (b:fs, bs)
+ let (bodyblocks, backblocks) = foldr splitBackBlocks ([],[]) blocks
let colwidth = if writerWrapText opts == WrapAuto
then Just $ writerColumns opts
else Nothing
metadata <- metaToContext opts
- fromBlocks
+ (blocksToJATS opts)
(fmap chomp . inlinesToJATS opts)
meta
- main <- fromBlocks bodyblocks
+ main <- blocksToJATS opts bodyblocks
notes <- gets (reverse . map snd . jatsNotes)
- backs <- fromBlocks backblocks
+ backs <- blocksToJATS opts backblocks
tagSet <- asks jatsTagSet
-- In the "Article Authoring" tag set, occurrence of fn-group elements
-- is restricted to table footers. Footnotes have to be placed inline.