Personal notes about how to use Pandoc. Though, honestly, their website (https://pandoc.org/) is pretty good and you should just go there.
Markdown to HTML
pandoc input.md -f markdown -t html --table-of-contents -s -o output.html
MathML
See also /mathml notes.
echo '$\lim_{n\to\infty}n$' | pandoc --mathml
Outputs:
<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mo>lim</mo><mrow><mi>n</mi><mo>→</mo><mi>∞</mi></mrow></msub><mi>n</mi></mrow><annotation encoding="application/x-tex">\lim_{n\to\infty}n</annotation></semantics></math></p>
Which looks like:
LaTeX to (X)HTML
Use “-s
” for standalone documents, without it you get an HTML fragment.
pandoc -s --mathml -o some-output.xhtml pandocmacros.tex some-section-to-convert.tex
Including macros
Sometimes in LaTeX you use macros so you don’t have to type as much math formatting. Maybe you have some macros like:
% Math stuff
\newcommand{\ud}{\,\mathrm{d}}
\newcommand{\Reals}{\mathbb{R}}
\newcommand{\Normal}{\mathsf{Normal}}
\DeclareMathOperator{\Utility}{U}
\DeclareMathOperator{\Value}{V}
\DeclareMathOperator{\Var}{Var}
Say you have these macros in a file called “pandocmacros.tex
”.
You can include them with:
pandoc -s --mathml -o some-output.xhtml pandocmacros.tex some-section-to-convert.tex