I'd like to distribute my notes as standalone html files. They contain both maths to be rendered with mathjax and figures.
The problem is that enabling both --self-contained and --mathjax ends with error message:
pandoc: user error (https not supported)
But even if I provide an url without https, mathjax fails to load any of its assets.
I am also having this issue. Running with --mathjax but without --self-contained will make the mathjax formulas render properly. Also running with --stand-alone but without --mathjax will also stop the error. It seems that the combination of both is causing the issue.
To follow up, I believe the issue is related to how pandoc embeds the MathJax.js script. By default pandoc tries to fetch the MathJax.js script from the https address, which does not appear to be supported by Haskell. If you pass the http address for the script it will be embedded but the embedding seems to have issues.
We get the error message: "Failed to load: /extensions/MathZoom.js" in the browser.
Given the way these extensions are loaded by the script, I don't see a good way for --self-contained to handle them. We might have to be content with a note in README that --mathjax won't work with --self-contained.
Added note to README with 68272fa.
I can't think of a way to get --self-contained to work properly with --mathjax, so this bit of documentation will have to do.
I understand that --self-contained does not work with --mathjax and have accepted that limitation, though I would like to request a halfway measure.
Is there an option to URL encode all the images and CSS while still forcing mathjax to link to external files?
That way my HTML document can contained almost all the necessary files and be easier to pass around or post on a webpage. Is this currently possible or easy to implement?
Seconding Jared's request. I don't mind pulling stuff off of CDNs, but I'd like to have a distributable HTML file that includes embedded images, which Pandoc is amazing for.
There is a hack you can do to get everything self-contained except for MathJax. Put the following code into your default.html template:
I surrounded it in a $if(mathjaxcdn)$...$endif$ block and activate it by setting a key later, but that's not necessary. Then you run pandoc --self-contained --mathjax=""
pandoc --self-contained --mathjax=""
I guess you could also put that script in a file (dynoload.js) and then pass that to pandoc (pandoc --self-contained --mathjax=dynoload.js). Maybe.
pandoc --self-contained --mathjax=dynoload.js
SORRY I got mixed up with -s (--standalone). I'll not delete my comment because this still might be useful for somebody wanting to create a presentation/document that has all files locally installed.
I don't see what the problem is (except that the approach I'm using is very verbose).
Setup: clone Reveal.js and MathJax (actually I have them as submodules), and then create an example.md
% My Talk
pandoc --mathjax=MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML -t revealjs -s example.md -o example.html
and I seem to have both revealjs and mathjax running from my local copies, so should work offline.
I understand that reveal.js tries to pull in mathjax automatically as an async plugin, I've not confirmed that it is not trying to use the CDN instead of my local copy.
I think there could be a self-contained document with mathjax:
What about letting mathjax render the math-blocks (i.e. as svg) when the document is created and embed only the rendered blocks, not mathjax itself?
@balachia Putting your script into an js-file and pass it with --mathjax=dynoload.js works, not nice but at least it works...