git.iko.soy/typeable/pandoc
on master help sign in
Use revealjs's math plugin for mathjax.

This is a thin wrapper around mathjax that makes math look better on revealjs. See https://github.com/hakimel/reveal.js/#mathjax We do this by setting the 'mathjax' boolean variable and using it in the revealjs template. Also, for revealjs and mathjax, we don't assign the usual thing to the 'math' variable, since it's handled by mathjax config. Closes #3743.

commitec3992b2f0aef0eefb85bdb693adfd0969126f7d authorJohn MacFarlane <jgm@berkeley.edu> dateSun 18 Jun 2017, 11:41 (9 years ago) parentabd2e94
2 files changed+18−3
data/templates/default.revealjs+11−2 src/Text/Pandoc/Writers/HTML.hs+7−1
data/templates/default.revealjs+11−2
@@ -229,15 +229,24 @@ $endif$
229229$if(maxScale)$
230230 maxScale: $maxScale$,
231231$endif$
232+$if(mathjax)$
233+ math: {
234+ mathjax: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js',
235+ config: 'TeX-AMS_HTML-full',
236+ },
237+$endif$
232238
233239 // Optional reveal.js plugins
234240 dependencies: [
235241 { src: '$revealjs-url$/lib/js/classList.js', condition: function() { return !document.body.classList; } },
236242 { src: '$revealjs-url$/plugin/zoom-js/zoom.js', async: true },
237− $if(notes-server)$
243+$if(notes-server)$
238244 { src: '$revealjs-url$/socket.io/socker.io.js', async: true },
239245 { src: '$revealjs-url$/plugin/notes-server/client.js', async: true },
240− $endif$
246+$endif$
247+$if(mathjax)$
248+ { src: '$revealjs-url$/plugin/math/math.js', async: true },
249+$endif$
241250 { src: '$revealjs-url$/plugin/notes/notes.js', async: true }
242251 ]
243252 });
src/Text/Pandoc/Writers/HTML.hs+7−1
@@ -253,7 +253,9 @@ pandocToHtml opts (Pandoc meta blocks) = do
253253 H.script ! A.src (toValue url)
254254 ! A.type_ "text/javascript"
255255 $ mempty
256− MathJax url ->
256+ MathJax url
257+ | slideVariant /= RevealJsSlides ->
258+ -- mathjax is handled via a special plugin in revealjs
257259 H.script ! A.src (toValue url)
258260 ! A.type_ "text/javascript"
259261 $ case slideVariant of
@@ -285,6 +287,10 @@ pandocToHtml opts (Pandoc meta blocks) = do
285287 (if stMath st
286288 then defField "math" (renderHtml' math)
287289 else id) $
290+ defField "mathjax"
291+ (case writerHTMLMathMethod opts of
292+ MathJax _ -> True
293+ _ -> False) $
288294 defField "quotes" (stQuotes st) $
289295 maybe id (defField "toc" . renderHtml') toc $
290296 defField "author-meta" authsMeta $