@@ -666,15 +666,18 @@ mathMLToTeXMath s = writeTeX <$> readMathML s
666666pMath :: Bool -> TagParser Inlines
667667pMath inCase = try $ do
668668 open@(TagOpen _ attr) <- pSatisfy $ tagOpen (=="math") (const True)
669− unless (inCase) (guard (maybe False (== mathMLNamespace) (lookup "xmlns" attr)))
669+ -- we'll assume math tags are MathML unless specially marked
670+ -- otherwise...
671+ unless inCase $
672+ guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr))
670673 contents <- manyTill pAnyTag (pSatisfy (~== TagClose "math"))
671− let math = mathMLToTeXMath $
672− (renderTags $ [open] ++ contents ++ [TagClose "math"])
673− let constructor =
674− maybe B.math (\x -> if (x == "inline") then B.math else B.displayMath)
675− (lookup "display" attr)
676− return $ either (const mempty)
677− (\x -> if null x then mempty else constructor x) math
674+ case mathMLToTeXMath (renderTags $ [open] ++ contents ++ [TagClose "math"]) of
675+ Left _ -> return $ B.spanWith ("",["math"],attr) $ B.text $
676+ innerText contents
677+ Right [] -> return mempty
678+ Right x -> return $ case lookup "display" attr of
679+ Just "block" -> B.displayMath x
680+ _ -> B.math x
678681
679682pInlinesInTags :: String -> (Inlines -> Inlines)
680683 -> TagParser Inlines