Skip to content

Commit

Permalink
HTML writer: render raw inline environments when --mathjax used.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jgm committed Jul 26, 2017
1 parent 2daab57 commit e0ab096
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Text/Pandoc/Writers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,9 +1007,14 @@ inlineToHtml opts inline = do
ishtml <- isRawHtml f
if ishtml
then return $ preEscapedString str
else do
report $ InlineNotRendered inline
return mempty
else if (f == Format "latex" || f == Format "tex") &&
"\\begin" `isPrefixOf` str &&
allowsMathEnvironments (writerHTMLMathMethod opts) &&
isMathEnvironment str
then inlineToHtml opts $ Math DisplayMath str
else do
report $ InlineNotRendered inline
return mempty
(Link attr txt (s,_)) | "mailto:" `isPrefixOf` s -> do
linkText <- inlineListToHtml opts txt
obfuscateLink opts attr linkText s
Expand Down
29 changes: 29 additions & 0 deletions test/command/3816.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
```
% pandoc --mathjax -t html5
This is an equation:
\begin{equation}
y+2 = 3
\end{equation}
This is a system of equations:
\begin{align*}
x^2+y^2 & = 2 \\
\sin(y) & = 0.5
\end{align*}
This is Euler's formula:
\begin{eqnarray*}
e^{i\pi} + 1 & = & 0.
\end{eqnarray*}
^D
<p>This is an equation: <span class="math display">\[\begin{equation}
y+2 = 3
\end{equation}\]</span></p>
<p>This is a system of equations: <span class="math display">\[\begin{align*}
x^2+y^2 &amp; = 2 \\
\sin(y) &amp; = 0.5
\end{align*}\]</span></p>
<p>This is Euler’s formula: <span class="math display">\[\begin{eqnarray*}
e^{i\pi} + 1 &amp; = &amp; 0.
\end{eqnarray*}\]</span></p>
```

0 comments on commit e0ab096

Please sign in to comment.