Is it possible to build a lightweight typst math rendering engine for the web, similar to KaTeX or MathJax?

I’m interested in building a typst math renderer similar to KaTeX/MathJax, so that people could write typst math instead of LaTeX in Markdown on sites like GitHub, with the equations rendered on the client side.

I’m aware that the typst engine has already been compiled to WASM, but it is quite heavy.

So I’m wondering whether it would be possible to build a lightweight typst math rendering engine in WASM, comparable in size to KaTeX or MathJax. Would it be possible to separate only the math rendering logic from the typst Rust crates, without loading the entire typst engine that handles full document layout?

My goal is to make the renderer as lightweight as possible.

BTW, do you think people would actually want to write Markdown + typst math instead of pure typst for blog posts, GitHub discussions, or similar contexts?

4 Likes

I think this would be useful for Jupyter for example as well, if you’d want to write math in typst syntax in a notebook.

4 Likes

See also (duplicate of) Does MathJax/KaTeX-like math typesetting for the web, but with Typst math syntax, exist?

This is not exactly duplicated. I just want to know, to reach lightweight, is it possible to use only typst crates, or would I have to build it from scratch if rendering math without setting up the whole layout turns out to be impossible?

1 Like