aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-10-01 17:46:13 -0700
committerJohn MacFarlane <[email protected]>2022-10-01 17:46:13 -0700
commitdd07d8002fb01b7e4c4987dc78ff74b886fb4539 (patch)
tree91ef95582f70ee265a62d31c1eeebec6c68e3c9b /src
parent89e7e9b636d2364ef766b97c533dc3f685a794d6 (diff)
JATS writer: use `<break/>` for LineBreak...
in the limited contexts that accept it. Closes #8344.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/JATS.hs13
-rw-r--r--src/Text/Pandoc/Writers/JATS/Table.hs7
2 files changed, 17 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs
index 7847f2bda..b9ecafa0e 100644
--- a/src/Text/Pandoc/Writers/JATS.hs
+++ b/src/Text/Pandoc/Writers/JATS.hs
@@ -135,8 +135,11 @@ docToJATS opts (Pandoc meta blocks) = do
formatTime defaultTimeLocale "%F" day)
]
Just x -> x
+ title' <- inlinesToJATS opts $ map fixLineBreak
+ (lookupMetaInlines "title" meta)
let context = defField "body" main
$ defField "back" back
+ $ resetField "title" title'
$ resetField "date" date
$ defField "mathml" (case writerHTMLMathMethod opts of
MathML -> True
@@ -249,6 +252,12 @@ codeAttr opts (ident,classes,kvs) = (lang, attr)
"platforms", "position", "specific-use"]]
lang = languageFor opts classes
+-- <break/> is only allowed as a direct child of <td> or <title> or
+-- <article-title>
+fixLineBreak :: Inline -> Inline
+fixLineBreak LineBreak = RawInline (Format "jats") "<break/>"
+fixLineBreak x = x
+
-- | Convert a Pandoc block element to JATS.
blockToJATS :: PandocMonad m => WriterOptions -> Block -> JATS m (Doc Text)
blockToJATS _ Null = return empty
@@ -257,7 +266,7 @@ blockToJATS opts (Div (id',"section":_,kvs) (Header _lvl _ ils : xs)) = do
| not (T.null id')]
let otherAttrs = ["sec-type", "specific-use"]
let attribs = idAttr ++ [(k,v) | (k,v) <- kvs, k `elem` otherAttrs]
- title' <- inlinesToJATS opts ils
+ title' <- inlinesToJATS opts (map fixLineBreak ils)
contents <- blocksToJATS opts xs
return $ inTags True "sec" attribs $
inTagsSimple "title" title' $$ contents
@@ -287,7 +296,7 @@ blockToJATS opts (Div (ident,_,kvs) bs) = do
"content-type", "orientation", "position"]]
return $ inTags True "boxed-text" attr contents
blockToJATS opts (Header _ _ title) = do
- title' <- inlinesToJATS opts title
+ title' <- inlinesToJATS opts (map fixLineBreak title)
return $ inTagsSimple "title" title'
-- No Plain, everything needs to be in a block-level tag
blockToJATS opts (Plain lst) = blockToJATS opts (Para lst)
diff --git a/src/Text/Pandoc/Writers/JATS/Table.hs b/src/Text/Pandoc/Writers/JATS/Table.hs
index 56aef3b87..7f0c614d0 100644
--- a/src/Text/Pandoc/Writers/JATS/Table.hs
+++ b/src/Text/Pandoc/Writers/JATS/Table.hs
@@ -234,8 +234,13 @@ tableCellToJats :: PandocMonad m
tableCellToJats opts ctype colAlign (Cell attr align rowspan colspan item) = do
blockToJats <- asks jatsBlockWriter
inlinesToJats <- asks jatsInlinesWriter
+ let fixBreak LineBreak = RawInline (Format "jats") "<break/>"
+ fixBreak x = x
let cellContents = \case
- [Plain inlines] -> inlinesToJats opts inlines
+ [Plain inlines] -> inlinesToJats opts
+ (map fixBreak inlines)
+ -- Note: <break/> is allowed only as a direct
+ -- child of <td>, so we don't use walk.
blocks -> blockToJats needsWrapInCell opts blocks
let tag' = case ctype of
BodyCell -> "td"