git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: render raw inline environments when --mathjax used.

We previously did this only with raw blocks, on the assumption that math environments would always be raw blocks. This has changed since we now parse them as inline environments. Closes #3816.

commite0ab09611a8ab42c69da81ed3fd3c3df8c0c70de authorJohn MacFarlane <jgm@berkeley.edu> dateWed 26 Jul 2017, 12:50 (9 years ago) parent2daab57
2 files changed+37−3
src/Text/Pandoc/Writers/HTML.hs+8−3 test/command/3816.md+29
src/Text/Pandoc/Writers/HTML.hs+8−3
@@ -1007,9 +1007,14 @@ inlineToHtml opts inline = do
10071007 ishtml <- isRawHtml f
10081008 if ishtml
10091009 then return $ preEscapedString str
1010− else do
1011− report $ InlineNotRendered inline
1012− return mempty
1010+ else if (f == Format "latex" || f == Format "tex") &&
1011+ "\\begin" `isPrefixOf` str &&
1012+ allowsMathEnvironments (writerHTMLMathMethod opts) &&
1013+ isMathEnvironment str
1014+ then inlineToHtml opts $ Math DisplayMath str
1015+ else do
1016+ report $ InlineNotRendered inline
1017+ return mempty
10131018 (Link attr txt (s,_)) | "mailto:" `isPrefixOf` s -> do
10141019 linkText <- inlineListToHtml opts txt
10151020 obfuscateLink opts attr linkText s
test/command/3816.mdnew file+29
@@ -0,0 +1,29 @@
1+```
2+% pandoc --mathjax -t html5
3+This is an equation:
4+\begin{equation}
5+y+2 = 3
6+\end{equation}
7+
8+This is a system of equations:
9+\begin{align*}
10+x^2+y^2 & = 2 \\
11+\sin(y) & = 0.5
12+\end{align*}
13+
14+This is Euler's formula:
15+\begin{eqnarray*}
16+e^{i\pi} + 1 & = & 0.
17+\end{eqnarray*}
18+^D
19+<p>This is an equation: <span class="math display">\[\begin{equation}
20+y+2 = 3
21+\end{equation}\]</span></p>
22+<p>This is a system of equations: <span class="math display">\[\begin{align*}
23+x^2+y^2 &amp; = 2 \\
24+\sin(y) &amp; = 0.5
25+\end{align*}\]</span></p>
26+<p>This is Euler’s formula: <span class="math display">\[\begin{eqnarray*}
27+e^{i\pi} + 1 &amp; = &amp; 0.
28+\end{eqnarray*}\]</span></p>
29+```