summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/HTML.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs19
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