Skip to content

Commit 9bb67d6

Browse files
josephcsiblejgm
authored andcommitted
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.
1 parent a63cf06 commit 9bb67d6

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Text/Pandoc/Readers/HTML.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -927,25 +927,21 @@ pMath inCase = try $ do
927927
let attr = toStringAttr attr'
928928
unless inCase $
929929
guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr))
930-
let isDisplay = case lookup "display" attr of
931-
Just "block" -> True
932-
_ -> False
930+
let constructor = case lookup "display" attr of
931+
Just "block" -> B.displayMath
932+
_ -> B.math
933933
contents <- manyTill pAny (pSatisfy (matchTagClose "math"))
934934
-- KaTeX and others include original TeX in annotation tag;
935935
-- just use this if present rather than parsing MathML:
936936
case extractTeXAnnotation contents of
937-
Just x -> return $ if isDisplay
938-
then B.displayMath x
939-
else B.math x
937+
Just x -> return $ constructor x
940938
Nothing ->
941939
case mathMLToTeXMath (renderTags $
942940
[open] <> contents <> [TagClose "math"]) of
943941
Left _ -> return $ B.spanWith ("",["math"],attr) $ B.text $
944942
innerText contents
945943
Right "" -> return mempty
946-
Right x -> return $ if isDisplay
947-
then B.displayMath x
948-
else B.math x
944+
Right x -> return $ constructor x
949945

950946
extractTeXAnnotation :: [Tag Text] -> Maybe Text
951947
extractTeXAnnotation [] = Nothing

0 commit comments

Comments
 (0)