Hacker News new | ask | show | jobs
by lahvak 1184 days ago
Do you want the TeX code to be converted to svg in the browser at rendering time or are you ok with converting the figures to svg beforehand and including them in your html files?

For the former I would look at TikZjaX (https://github.com/kisonecat/tikzjax) which takes tikz code and convert it to svg on the fly, just like MathJaX converting TeX equations. It may be slow, though, especially for complicated plots.

If you are OK with creating the figures beforehand and serving the generated svg, there are several options: Asymptote (https://asymptote.sourceforge.io/) can generate svg and even html files that you can embed in an iframe. You can convert any TeX figure to svg with dvisvgm (play with the --font-format option). If you insists on using pstricks, I am pretty sure you can convert a resulting postscript file to svg as well. If you are using metapost, then mptopdf will convert metapost source to pdf, which you can then convert to svg.

1 comments

Thanks, the main thing I want is to be able to embed the generating code directly into the markdown file, server side rendering is fine too as long as it does not involve me manually converting them.

If there is a way to script in an Asymptote render step into MdBook that would be ideal, otherwise I’ll need to chain it with GitHub actions or something like that…