aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph C. Sible <[email protected]>2024-12-14 02:30:58 -0500
committerJohn MacFarlane <[email protected]>2024-12-14 17:08:53 -0800
commit9bb67d666f574c78529203b2737a6e81a7753fc9 (patch)
treeee1df6088b333ad60def533c9f2a9ab3354831b2
parenta63cf069e35046411af87f67e21da603f8303393 (diff)
Store a function instead of a Boolean
Instead of storing isDisplay and then always choosing displayMath or math based on that, just store displayMath or math directly.
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 74366a04d..b1e23ef9e 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -927,25 +927,21 @@ pMath inCase = try $ do
let attr = toStringAttr attr'
unless inCase $
guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr))
- let isDisplay = case lookup "display" attr of
- Just "block" -> True
- _ -> False
+ let constructor = case lookup "display" attr of
+ Just "block" -> B.displayMath
+ _ -> B.math
contents <- manyTill pAny (pSatisfy (matchTagClose "math"))
-- KaTeX and others include original TeX in annotation tag;
-- just use this if present rather than parsing MathML:
case extractTeXAnnotation contents of
- Just x -> return $ if isDisplay
- then B.displayMath x
- else B.math x
+ Just x -> return $ constructor x
Nothing ->
case mathMLToTeXMath (renderTags $
[open] <> contents <> [TagClose "math"]) of
Left _ -> return $ B.spanWith ("",["math"],attr) $ B.text $
innerText contents
Right "" -> return mempty
- Right x -> return $ if isDisplay
- then B.displayMath x
- else B.math x
+ Right x -> return $ constructor x
extractTeXAnnotation :: [Tag Text] -> Maybe Text
extractTeXAnnotation [] = Nothing