diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-11-02 16:14:25 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-11-02 16:43:36 +0100 |
commit | bdda4b185bdab5e4eb56a1ce422f4efebdb5ace9 (patch) | |
tree | d991be6226c9d415f1e4505b0d232477268a3d63 /src/Text/Pandoc | |
parent | 705df61198f6cab21f81b6aba191d6602bf14fdc (diff) | |
download | pandoc-bdda4b185bdab5e4eb56a1ce422f4efebdb5ace9.tar.gz |
HTML reader: treat `<math>` as MathML by default...
unless something else is explicitly specified in xmlns.
Provided it parses as MathML, of course.
Also fixed default which should be to inline math if no
display attribute is used.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index 8ce3fa379..10a2976e5 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -666,15 +666,18 @@ mathMLToTeXMath s = writeTeX <$> readMathML s pMath :: Bool -> TagParser Inlines pMath inCase = try $ do open@(TagOpen _ attr) <- pSatisfy $ tagOpen (=="math") (const True) - unless (inCase) (guard (maybe False (== mathMLNamespace) (lookup "xmlns" attr))) + -- we'll assume math tags are MathML unless specially marked + -- otherwise... + unless inCase $ + guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr)) contents <- manyTill pAnyTag (pSatisfy (~== TagClose "math")) - let math = mathMLToTeXMath $ - (renderTags $ [open] ++ contents ++ [TagClose "math"]) - let constructor = - maybe B.math (\x -> if (x == "inline") then B.math else B.displayMath) - (lookup "display" attr) - return $ either (const mempty) - (\x -> if null x then mempty else constructor x) math + case mathMLToTeXMath (renderTags $ [open] ++ contents ++ [TagClose "math"]) of + Left _ -> return $ B.spanWith ("",["math"],attr) $ B.text $ + innerText contents + Right [] -> return mempty + Right x -> return $ case lookup "display" attr of + Just "block" -> B.displayMath x + _ -> B.math x pInlinesInTags :: String -> (Inlines -> Inlines) -> TagParser Inlines |