git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: render inline formulas correctly with --webtex (#5656)

We add `\textstyle` to the beginning of the formula to ensure it will be rendered in inline style. Closes #5655.

commitbc508534a648b900c683e60b1cc9681ed606a723 authorPhilip Pesca <phil.pesca@gmail.com> dateTue 23 Jul 2019, 12:21 (7 years ago) parentdb5f6dd
2 files changed+18−1
src/Text/Pandoc/Writers/HTML.hs+4−1 test/command/5655.md+14
src/Text/Pandoc/Writers/HTML.hs+4−1
@@ -1062,8 +1062,11 @@ inlineToHtml opts inline = do
10621062 case writerHTMLMathMethod opts of
10631063 WebTeX url -> do
10641064 let imtag = if html5 then H5.img else H.img
1065+ let s = case t of
1066+ InlineMath -> "\\textstyle "
1067+ DisplayMath -> ""
10651068 let m = imtag ! A.style "vertical-align:middle"
1066− ! A.src (toValue $ url ++ urlEncode str)
1069+ ! A.src (toValue $ url ++ urlEncode (s ++ str))
10671070 ! A.alt (toValue str)
10681071 ! A.title (toValue str)
10691072 let brtag = if html5 then H5.br else H.br
test/command/5655.mdnew file+14
@@ -0,0 +1,14 @@
1+````
2+% pandoc --webtex
3+$T_n={n+1 \choose 2}$
4+^D
5+<p><img style="vertical-align:middle" src="https://latex.codecogs.com/png.latex?%5Ctextstyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" /></p>
6+````
7+
8+````
9+% pandoc --webtex
10+$$T_n={n+1 \choose 2}$$
11+^D
12+<p><br /><img style="vertical-align:middle" src="https://latex.codecogs.com/png.latex?T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" /><br /></p>
13+````
14+