Open cderv opened 3 years ago
Are there any changes that make sense now? Or is this more a reminder to modify things when the new release of reveal.js is out?
The change that makes sense now would be to use Mathjax 2 by default with reveals format, if this is possible to tweak the option value for this format only.
Probably https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-MML-AM_CHTML or the one advide in the doc http://docs.mathjax.org/en/v2.7-latest/start.html
Then, to support Mathjax 3 and Katex, some change in template and probably other logic in the writer will be needed I think.
Not easy to do this -- at the point where we insert the default mathjax URL, we don't yet necessarily know what the output format will be. And we don't want to override an explicitly given URL.
I am not sure to see how to fix without changing the default for revealjs.
I don't know when the next revealjs version will be out, but if soon, it could worth the wait and adapt the template to use the plugin compatible with Mathjax 3 then. I am just not sure how to adapt the template if someone provide a mathjax url for version 2. Maybe a documentation note saying that --mathjax
with revealjs only work with version 3 unless a custom template is used - not great though 😓
There is time to see how to adapt in Pandoc. In our tool, we are overring the default mathjax url to solve this issue.
It's easy enough for users to manually specify the URL with --mathjax
, if they know that they need to do this. Hopefully they'll find this issue if they search.
FWIW new reveal.js version is out https://github.com/hakimel/reveal.js/releases/tag/4.2.0
Supporting Mathjax 3 by default to go with the default mathjax-url
would mean modifying the Pandoc template in this way
diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs
index 203983522..d4f839719 100644
--- a/data/templates/default.revealjs
+++ b/data/templates/default.revealjs
@@ -303,7 +303,7 @@ $endif$
// reveal.js plugins
plugins: [
$if(mathjax)$
- RevealMath,
+ RevealMath.MathJax3,
$endif$
RevealNotes,
RevealSearch,
but if someone wanted to use Mathjax 2 using mathjax-url
, it would need to be RevealMath
or RevealMath.Mathjax2
.
Same if someone would change the revealjs-url
to using an older version.
Also, --katex
could be now supported with RevealMath.KaTeX
with new version 4.2.0 of reveal.js
Anyway, as I said before, I do not know how Pandoc could handle the conditional between mathjax-url
value and the plugin value to use.
Writing this here in case anyone is looking for such information.
Take this simple example in
test.md
When I convert to revealjs format using
this will create a HTML document throwing this issue in the browser console
This is from the
revealMath
plugin inserted by Pandoc when mathjax is used. https://github.com/jgm/pandoc/blob/c256ef34b32308f00b64ca9cb01f1bacd5994802/data/templates/default.revealjs#L308-L310This plugin is compatible with mathjax 2 and not 3. The error is thrown because
MathJax.Hub.Config()
does not exist anymore in Mathjax 3. http://docs.mathjax.org/en/latest/upgrading/v2.html#configuration-changes but Pandoc uses 3 by default : https://github.com/jgm/pandoc/blob/25a86fc06fd5d7e07251ca9bd758cc42c4234d70/src/Text/Pandoc/Options.hs#L369So Math in revealjs slide made with Pandoc does not work well unless the default Mathjax URL is changed.
revealMath
plugin is not compatible with mathjax 3 in last released version, there was an issue about that https://github.com/hakimel/reveal.js/issues/2559#issuecomment-629389857, but as you can see in the issue, improvement has been been made to support Mathjax 2, MathJax 3 and Katex.So next version of revealjs will change the way the plugin is working. Default will still be Mathjax 2 so the compatibility issue will remain. But it can be configured to version 3 or even with Katex, which could help bring support to Pandoc's
--katex
flag.Changes for next reveal.js version were done here: https://github.com/hakimel/reveal.js/commit/0ea419300162bfc78f294c22a12046028e6605a7