Experimental LaTeX parser and renderer in book example
This is implemented using the new pulldown_cmark 0.11 version which supports simple math parsing (which is still not published, so for now we pull it from Git)
The renderer calls out to MathJax with mathjax_svg (which embeds the V8 engine into the executable :trollface: and uses MathJax to convert LaTeX into an svg). This is then rendered as an egui image using egui_extra's svg feature (which uses Resvg).
This doesn't really have to be LaTeX, since the entirety of rendering math expressions is handled by the user, not egui_commonmark. Never really tried to mess with Typst, but it could be entirely possible to implement it.
TODO: proper error handling, math feature, center text horizontally with math equations, select and copy equations, implement Typst rendering
closes https://github.com/lampsitter/egui_commonmark/issues/25
I'm actually super interested in this. What's the current status?
I'm actually super interested in this. What's the current status?
It's pretty much ready, it just passes the LaTeX to the user whenever it needs to render it. The only downside is that you basically cannot render LaTeX with pure Rust, without somehow calling a JS engine to ask MathJax to render it for you It also should be possible to use Typst instead of LaTeX as that is written in Rust, but I haven't experimented with it. The internals of this library have changed quite a lot since this PR, so it might also take some work to update it
Is it possible to achieve dark theme support for a book when using mathjax_svg? As far as I can tell - it only generates svg for light.
Something to look into: https://github.com/NanoMichael/MicroTeX