I hacked together some code that will render the equations on the server:
Thereās no error handling, and the font size doesnāt quite match the client-side version, but it seems to basically work in my development environment.
I really like the idea of this, should help performance quite a bit in some cases and starts unlocking email support! We still need to convert svg to png at some point for email.
Got to keep it optional for accessibility reasons though
Because plugin development is currently way above my league, I just wanted to try adding KaTex via custom theme, using the autorender Katex extension. It kinda worked, but I ran into an issue with supporting a single $ sign as a math delimiter.
It seems that even though I turned off the MathJax math plugin, the text enclosed in $ $ is converted to text inside <span class=math> and the dollar signs dissappear. Weirdly, I cannot reproduce this on META. Any ideas?
Yeah the auto render stuff if very likely going to be extremely janky on Discourse. We rely on proper hooks that ādecorateā chunks of HTML as they are being added to the DOM. We got to do this thing properly.
Maybe @misaka4e21 can have a look at making KaTeX optional default off in the math plugin?
One thing to consider. KaTex still lacks certain features as compared to MathJax. In Khan Academy, they actually fallback to MathJax when KaTeX fails. This would probably make sense to implement once the server-side rendering is in place, cause otherwise youād always need to ship both Katex and mathjax, which is likely undesirable.
I am not actually involved directly, but my guess would be simply when KaTex throws an error they use MathJax?
And I am pretty sure they do it on the client as well.
For more info Iād suggest asking them directly on their github.