git.iko.soy/typeable/pandoc
on master help sign in
MediaWiki writer: add display attribute on `<math>` tags.

This allows display math to be rendered properly. Closes #3452.

commite462f80d74e7d0297ae96dc8bd57cb66dcccfa71 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 21 Feb 2017, 22:57 (10 years ago) parent5269724
2 files changed+12−9
src/Text/Pandoc/Writers/MediaWiki.hs+5−2 test/writer.mediawiki+7−7
src/Text/Pandoc/Writers/MediaWiki.hs+5−2
@@ -388,8 +388,11 @@ inlineToMediaWiki (Code _ str) =
388388
389389inlineToMediaWiki (Str str) = return $ escapeString str
390390
391−inlineToMediaWiki (Math _ str) = return $ "<math>" ++ str ++ "</math>"
392− -- note: str should NOT be escaped
391+inlineToMediaWiki (Math mt str) = return $
392+ "<math display=\"" ++
393+ (if mt == DisplayMath then "block" else "inline") ++
394+ "\">" ++ str ++ "</math>"
395+ -- note: str should NOT be escaped
393396
394397inlineToMediaWiki (RawInline f str)
395398 | f == Format "mediawiki" = return str
test/writer.mediawiki+7−7
@@ -469,13 +469,13 @@ Ellipses…and…and….
469469= LaTeX =
470470
471471*
472−* <math>2+2=4</math>
473−* <math>x \in y</math>
474−* <math>\alpha \wedge \omega</math>
475−* <math>223</math>
476−* <math>p</math>-Tree
477−* Here’s some display math: <math>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
478−* Here’s one that has a line break in it: <math>\alpha + \omega \times x^2</math>.
472+* <math display="inline">2+2=4</math>
473+* <math display="inline">x \in y</math>
474+* <math display="inline">\alpha \wedge \omega</math>
475+* <math display="inline">223</math>
476+* <math display="inline">p</math>-Tree
477+* Here’s some display math: <math display="block">\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
478+* Here’s one that has a line break in it: <math display="inline">\alpha + \omega \times x^2</math>.
479479
480480These shouldn’t be math:
481481