git.iko.soy/typeable/pandoc
on master help sign in
Fix regression with tex math environments in HTML + MathJax.

Closes #4639.

commitd3be567a73478298485f66b2d2af5ca066eae052 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 9 May 2018, 10:37 (8 years ago) parent81881ce
2 files changed+15−11
src/Text/Pandoc/Writers/HTML.hs+5−11 test/command/4639.md+10
src/Text/Pandoc/Writers/HTML.hs+5−11
@@ -665,16 +665,11 @@ blockToHtml opts (Para [Image attr@(_,classes,_) txt (src,tit)])
665665-- title beginning with fig: indicates that the image is a figure
666666blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) =
667667 figure opts attr txt (s,tit)
668−blockToHtml opts (Para lst)
669− | isEmptyRaw lst = return mempty
670− | null lst && not (isEnabled Ext_empty_paragraphs opts) = return mempty
671− | otherwise = do
672− contents <- inlineListToHtml opts lst
673− return $ H.p contents
674− where
675− isEmptyRaw [RawInline f _] = f `notElem` [Format "html",
676− Format "html4", Format "html5"]
677− isEmptyRaw _ = False
668+blockToHtml opts (Para lst) = do
669+ contents <- inlineListToHtml opts lst
670+ case contents of
671+ Empty _ | not (isEnabled Ext_empty_paragraphs opts) -> return mempty
672+ _ -> return $ H.p contents
678673blockToHtml opts (LineBlock lns) =
679674 if writerWrapText opts == WrapNone
680675 then blockToHtml opts $ linesToPara lns
@@ -1063,7 +1058,6 @@ inlineToHtml opts inline = do
10631058 if ishtml
10641059 then return $ preEscapedString str
10651060 else if (f == Format "latex" || f == Format "tex") &&
1066− "\\begin" `isPrefixOf` str &&
10671061 allowsMathEnvironments (writerHTMLMathMethod opts) &&
10681062 isMathEnvironment str
10691063 then inlineToHtml opts $ Math DisplayMath str
test/command/4639.mdnew file+10
@@ -0,0 +1,10 @@
1+```
2+% pandoc -t html --mathjax
3+\begin{equation}
4+ E=mc^2
5+\end{equation}
6+^D
7+<p><span class="math display">\[\begin{equation}
8+ E=mc^2
9+\end{equation}\]</span></p>
10+```