From 56ce1fc12651e9cf60b882a18d72a410967d6540 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 24 Mar 2021 11:57:49 -0700 Subject: Fix DocBook reader mathml regression... ...caused by the switch in XML libraries. Also fixed a similar issue in JATS. Closes #7173. --- src/Text/Pandoc/Readers/DocBook.hs | 3 +- src/Text/Pandoc/Readers/JATS.hs | 8 ++- test/command/7173.md | 137 +++++++++++++++++++++++++++++++++++++ test/docbook-reader.docbook | 4 +- 4 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 test/command/7173.md diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 6f5bb0ad4..4f525cfb1 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -1239,7 +1239,8 @@ equation e constructor = where mathMLEquations :: [Text] mathMLEquations = map writeTeX $ rights $ readMath - (\x -> qName (elName x) == "math" && qPrefix (elName x) == Just "mml") + (\x -> qName (elName x) == "math" && + qURI (elName x) == Just "http://www.w3.org/1998/Math/MathML") (readMathML . showElement) latexEquations :: [Text] diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs index 602f3b4f2..c068f3774 100644 --- a/src/Text/Pandoc/Readers/JATS.hs +++ b/src/Text/Pandoc/Readers/JATS.hs @@ -491,7 +491,8 @@ parseInline (Elem e) = "disp-formula" -> formula displayMath "inline-formula" -> formula math - "math" | qPrefix (elName e) == Just "mml" -> return . math $ mathML e + "math" | qURI (elName e) == Just "http://www.w3.org/1998/Math/MathML" + -> return . math $ mathML e "tex-math" -> return . math $ textContent e "email" -> return $ link ("mailto:" <> textContent e) "" @@ -514,8 +515,9 @@ parseInline (Elem e) = filterChildren isMathML whereToLook return . mconcat . take 1 . map constructor $ texMaths ++ mathMLs - isMathML x = qName (elName x) == "math" && - qPrefix (elName x) == Just "mml" + isMathML x = qName (elName x) == "math" && + qURI (elName x) == + Just "http://www.w3.org/1998/Math/MathML" removePrefix elname = elname { qPrefix = Nothing } codeWithLang = do let classes' = case attrValue "language" e of diff --git a/test/command/7173.md b/test/command/7173.md new file mode 100644 index 000000000..2599dc19b --- /dev/null +++ b/test/command/7173.md @@ -0,0 +1,137 @@ +``` +% pandoc -f docbook -t latex + + + + +
+ Untitled Document + Word + + 1+2 + + + 1+2 + + + + +
+^D +Word + +\[1 + 2\] +``` + +``` +% pandoc -f docbook -t latex + + + + +
+ Untitled Document + Word + + 1+2 + + + 1+2 + + + + +
+^D +Word + +\[1 + 2\] +``` + +``` +% pandoc -f docbook -t latex + + + + +
+ Untitled Document + Word + + 1+2 + + + 1+2 + + + + +
+^D +Word + +\[1 + 2\] +``` + +``` +% pandoc -f docbook -t latex + + + + +
+ Untitled Document + Word + + 1+2 + + + 1+2 + + + + +
+^D +Word + +\[1 + 2\] +``` + +``` +% pandoc -f docbook -t latex + + + + +
+ Untitled Document + Word + + 1+2 + + + 1+2 + + + + +
+^D +Word + +\[1 + 2\] +``` + diff --git a/test/docbook-reader.docbook b/test/docbook-reader.docbook index 5717d78d0..51e62942b 100644 --- a/test/docbook-reader.docbook +++ b/test/docbook-reader.docbook @@ -6,7 +6,9 @@ ]> -
+
Pandoc Test Suite -- cgit v1.2.3