How to pre-render maths to images?

I am planning to use Typst to emit EPUB-ready XHTML once the HTML support is ready. However, since the ecosystem around MathML and E-Reader support for maths rendering is so haphazard, the only reliable way to include equations in an EPUB is embedding a pre-rendered image. I would like to know if there is a way to do this in Typst. Writing Rust is also not an issue, since I am proficient in the language.

1 Like

You mean this?

#set page(width: auto, height: auto, margin: 0pt)
#show math.equation: it => pagebreak(weak: true) + it

$ x = y $

$ a = b $

typst c file.typ 'equation{0p}.png' # svg

Typst supports emitting equations as svg using html.frame already in Typst 0.13 (experimentally). You could potentially test it already now, but I suppose this (svg) is not well enough supported by EPUB?