HTML writer: pass through \ref and \eqref...

if MathJax is used.

Closes #7587.
This commit is contained in:
John MacFarlane
2021-09-22 22:33:41 -07:00
parent 7ab2f4a61d
commit 0afb48cd38
+10 -2
View File
@@ -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 =