Same use case (math-heavy, no-javascript blog), but I ended up with a _slightly_ different approach: instead of converting to SVG, convert to MathML. Browser support is pretty robust, and the output is much nicer (e.g. preserves fonts).
MathML is part of HTML5 and standardised by ISO/IEC since 2015. It is supported by all major browsers and supports voicing as well as braille output.
This is the way to go.
bArray•5h ago
Same here [1], I chose MathML as it worked out of the box in some browsers at the time. For browsers not supporting MathML I also have this ~80kB (~12kB compressed) library for converting it [2]. I tested your equation:
I did previously also load the LaTeX equation font, but I decided it used a lot of resource for little gain in the end.
I was also looking at your recent blog [3], and one thing that I like about mine is that the code you see is what is run to produce the output [4]. I am in the middle of making the code interactive too, so that you can re-compile it within the web page and run different parameters to produce different outputs.
That test page doesn't seem to use any features current Chrome doesn't support. Or do you just mean that the appearance isn't identical to the TeX rendering even if you use a font like Latin Modern?
icpmoles•1h ago
It improved a little bit from what I remembered (on Chrome it had problems displaying multi-line brackets), it still has some inaccuracies tho
With Safari (standard and tech preview) the rendering looks strange (at least). The root sign does not have a strait line at the top (for many fonts) and at least the partial derivative is not rendered as italic (for all fonts).
ttd•2h ago
I still haven't found a way to coax MathML into looking the way I want it... Even using the same fonts (like Computer Modern or its descendants) there's still something not quite the same as LaTeX-drawn math. It's a nitpick but noticeable for me.
bobbylarrybobby•2h ago
What does it mean that it preserves fonts? Presumably the body font on my website won't also support math typesetting, right? Or at least, not in a way that's as nice looking as the tex default?
sathomasga•5h ago
https://sathomas.me/blog/site/
JadeNB•5h ago
randomtoast•5h ago
This is the way to go.
bArray•5h ago
I was also looking at your recent blog [3], and one thing that I like about mine is that the code you see is what is run to produce the output [4]. I am in the middle of making the code interactive too, so that you can re-compile it within the web page and run different parameters to produce different outputs.
[1] https://coffeespace.org.uk/projects/mathml-render.html
[2] https://github.com/pshihn/math-ml
[3] https://sathomas.me/blog/robuststats/
[4] https://coffeespace.org.uk/projects/wavefront-algorithm.html
icpmoles•3h ago
https://fred-wang.github.io/MathFonts/mozilla_mathml_test/
yorwba•3h ago
icpmoles•1h ago
https://imgur.com/a/83lSuYn
qrios•1h ago
With Safari (standard and tech preview) the rendering looks strange (at least). The root sign does not have a strait line at the top (for many fonts) and at least the partial derivative is not rendered as italic (for all fonts).
ttd•2h ago
bobbylarrybobby•2h ago