aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-09-22 22:33:00 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-09-22 22:33:41 -0700
commit0afb48cd384ea1663f88bda32d0d149dc9a6f6c5 (patch)
treeb5da86d58bd7deab9301c203bbca8207f39bb126 /src/Text
parent7ab2f4a61d43928f597cad4916d25a94a5bde0e8 (diff)
downloadpandoc-0afb48cd384ea1663f88bda32d0d149dc9a6f6c5.tar.gz
HTML writer: pass through `\ref` and `\eqref`...
if MathJax is used. Closes #7587.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 03d182f5e..f883bd6d8 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1469,8 +1469,9 @@ inlineToHtml opts inline = do
if ishtml
then return $ preEscapedText str
else if (f == Format "latex" || f == Format "tex") &&
- allowsMathEnvironments (writerHTMLMathMethod opts) &&
- isMathEnvironment str
+ ((allowsMathEnvironments (writerHTMLMathMethod opts) &&
+ isMathEnvironment str) ||
+ (allowsRef (writerHTMLMathMethod opts) && isRef str))
then inlineToHtml opts $ Math DisplayMath str
else do
report $ InlineNotRendered inline
@@ -1602,6 +1603,9 @@ inDiv cls x = do
(if html5 then H5.div else H.div)
x ! A.class_ (toValue cls)
+isRef :: Text -> Bool
+isRef t = "\\ref{" `T.isPrefixOf` t || "\\eqref{" `T.isPrefixOf` t
+
isMathEnvironment :: Text -> Bool
isMathEnvironment s = "\\begin{" `T.isPrefixOf` s &&
envName `elem` mathmlenvs
@@ -1641,6 +1645,10 @@ allowsMathEnvironments MathML = True
allowsMathEnvironments (WebTeX _) = True
allowsMathEnvironments _ = False
+allowsRef :: HTMLMathMethod -> Bool
+allowsRef (MathJax _) = True
+allowsRef _ = False
+
-- | List of intrinsic event attributes allowed on all elements in HTML4.
intrinsicEventsHTML4 :: [Text]
intrinsicEventsHTML4 =