From e5e2a6e0a5c1ef10375e4c94985b3247289d77e9 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 30 Mar 2017 16:22:54 +0200 Subject: [PATCH] JATS writer: use both tex and mml alternatives for math when possible. --- src/Text/Pandoc/Writers/JATS.hs | 12 +++++++----- test/writer.jats | 29 +++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index 5e1b3164b..71a45bf77 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -381,14 +381,16 @@ inlineToJATS _ (Math t str) = do let tagtype = case t of DisplayMath -> "disp-formula" InlineMath -> "inline-formula" - return $ inTagsSimple tagtype $ - case res of - Right r -> text $ Xml.ppcElement conf - $ fixNS r - Left _ -> inTagsSimple "tex-math" + let rawtex = inTagsSimple "tex-math" $ text " text str <> text "]]>" + return $ inTagsSimple tagtype $ + case res of + Right r -> inTagsSimple "alternatives" $ + cr <> rawtex $$ + (text $ Xml.ppcElement conf $ fixNS r) + Left _ -> rawtex inlineToJATS _ (Link _attr [Str t] ('m':'a':'i':'l':'t':'o':':':email, _)) | escapeURI t == email = return $ inTagsSimple "email" $ text (escapeStringForXML email) diff --git a/test/writer.jats b/test/writer.jats index ae72133a8..f498711f0 100644 --- a/test/writer.jats +++ b/test/writer.jats @@ -1048,39 +1048,52 @@ These should not be escaped: \$ \\ \> \[ \{

- 2+2=4 + + + 2+2=4

- xy + + + xy

- αω + + + αω

- 223 + + + 223

- p-Tree + + + p-Tree

- Here’s some display math: - ddxf(x)=limh0f(x+h)f(x)h + Here’s some display math: + + ddxf(x)=limh0f(x+h)f(x)h

Here’s one that has a line break in it: - α+ω×x2. + + + α+ω×x2.