Reputation: 310
Somewhat similar to How to convert HTML with mathjax into latex using pandoc? but in some sense, the opposite.
If I'm using Pandoc to create MD files with LaTeX, or even just MD files, how can I use Pandoc to convert these to HTML with the correct \(\)
, \[\]
tags for math?
Upvotes: 11
Views: 12404
Reputation: 4061
I just found mathjax-node-page (from html to html) and they are truly self-contained. From my Makefile:
# Convert
pandoc aperture_synthesis.md -t html --self-contained -s --standalone --mathjax -o aperture_synthesis.html
cp aperture_synthesis.html out1.html
# Independentize from MathJax CDN
$$HOME/Program/MathJax/node_modules/mathjax-node-page/bin/mjpage --output CommonHTML < out1.html > aperture_synthesis.html
Upvotes: 0
Reputation: 28487
Following discussion here, I am able to convert test.md
(containing LaTeX code) to test.html
successfully.
pandoc --toc --standalone --mathjax -f markdown -t html test.md -o test.html
The doc on --mathjax
can be found here:
Use MathJax to display embedded TeX math in HTML output. TeX math will be put between (...) (for inline math) or [...] (for display math) and wrapped in tags with class math. Then the MathJax JavaScript will render it. The URL should point to the MathJax.js load script. If a URL is not provided, a link to the Cloudflare CDN will be inserted.
The option --standalone
is important, without which the LaTeX code can not be rendered correctly.
PS. wrap inline equation like $INLINE EQUATION$
and wrap display equation like $$DISPLAY EQUATION$$
.
Upvotes: 21
Reputation: 39508
You want to convert from markdown to html with mathjax support?
pandoc --mathjax input.md -o output.html
Upvotes: 4
Reputation: 11322
Assuming Windows as platform, the following .CMD
snippet should do the conversion:
set PATH=%ProgramFiles%\pandoc;%PATH%
set CDN=http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
set IN=%~s1
if [%2]==[] (
set OUT=%~sdp1%~n1.html
) else (
set OUT=%~s2
)
echo Converting markdown to html ...
pandoc.exe -s --mathjax=%CDN% --from=markdown+pipe_tables --to=html --output="%OUT%" %IN%
Consult the pandoc help to tune the commandline parameters.
Upvotes: 1