This is a simple PanDoc filter that will converts all math blocks and raw LaTeX blocks to SVGs.
With this filter, you can start writing raw LaTeX in Markdown and get a neatly generated SVG in output HTML:
\begin{align*} \sum_{n=0}^\infty \frac{1}{n} &= \frac{1}{0!} + \frac{1}{1!} + \frac{1}{2!} + \dots \ &= 1+1+\frac{1}{2}+\frac{1}{6}+\dots \ &= \mathrm{e} \end{align*}
- You will need
pdftex
anddvisvgm
in order to use this filter. If you have TeX Live, you should be fine. - In
options.lua
, adjust values according to your setup:template
defines a minimal LaTeX document structure, used for producing a minimal SVG.preamble
defines the preamble of the intermediate LaTeX document. Include all your\usepackegs
there.pdftex_exe
defines the path to thepdftex
executable. It is used to generate advi
file from atex
document.pdftex_arg
defines the arguments used to runpdftex
.dvisvgm_exe
defines the path to thedvisvgm
executable. It is used to convertdvi
files tosvg
images.dvisvgm_arg
defines the arguments used to rundvisvgm
. The default arguments should be sufficient for general use cases.
- Use
--lua-filter
options while using pandoc, for example:pandoc --lua-filter latex2svg.lua -t html5 --self-contained -o README.html --metadata title="latex2svg-filter manual" README.markdown
One major reason of me pursuing this solution is to use environments like align*
and tikzpicture
.
As far as I know of, there is no alternatives that can render them without a real TeX setup.
Many thanks to a Haskell package called latex-svg
for inspring me to make this!