git.iko.soy/typeable/pandoc
on master help sign in
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.

commitbdda4b185bdab5e4eb56a1ce422f4efebdb5ace9 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 2 Nov 2016, 16:14 (10 years ago) parent705df61
1 file changed+11−8
src/Text/Pandoc/Readers/HTML.hs+11−8
src/Text/Pandoc/Readers/HTML.hs+11−8
@@ -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