Re:KaTeX – The fastest math typesetting library for the web
by vbernat on Sunday October 11, 2020 @02:58AM
(#24744204)
KaTeX can be generated server-side (no JS on client-side). Its output is browser-independent. It contains MathML in its output and the remaining of the output is correctly tagged to be ignored by readers:
This is:
[ Parent
| on HN ]
Re:KaTeX – The fastest math typesetting library for the web
by joppy on Sunday October 11, 2020 @03:53AM
(#24744349)
In my own experiments with mathematical writing, rendering KaTeX server-side increased the resulting HTML size by a nontrivial amount. I bet that if you took something small-textbook-sized, in terms of bytes it would be smaller to ship katex.js and get it to render the latex on the fly, rather than generating the HTML ahead of time.
Bit of a sad situation, but then again HTML and CSS is not really the best layout language for this kind of stuff.
Re:KaTeX – The fastest math typesetting library for the web
by snicker7 on Sunday October 11, 2020 @03:10AM
(#24744228)
JS on server-side can be taxing. If I don't use NodeJS, then I'd have to (1) call it from a script, eating the startup time (2) run a daemon of NodeJS workers running in parallel to my web server or (3) use an "embedded" JS engine, hoping I don't run into compatibility issues. All three options have performance costs + adds more dependencies.
If KaTeX were written in C, for example, it would be no problem FFI'ing it into just about any language. Plus whatever perf benefits there are of not using JS.
Re:KaTeX – The fastest math typesetting library for the web
by mbeex on Sunday October 11, 2020 @04:38AM
(#24744504)
He wrote "can be generated". You can use KaTeX for setting up complete static web pages with no JS/server-side prozessing at all. Example from my blog:
https://depot.traits.de/pages/2020/02/21-markdown-example.ht...
Re:KaTeX – The fastest math typesetting library for the web
by franga2000 on Sunday October 11, 2020 @04:42AM
(#24744521)
For the vast majority of use cases, you should probably be pre-generating these anyways, and for the few use cases where content would be constantly changing, client-side rendering makes way more sense.
Re:KaTeX – The fastest math typesetting library for the web
by joppy on Sunday October 11, 2020 @06:18AM
(#24744822)
The thing specifically with KaTeX is that if you do this, you can blow page sizes out completely. In the example above, less than 20 characters of latex turned into a giant amount of HTML markup. Repeat this in many places for a mathematics-heavy page, and the browser might be better off just running KaTeX itself. Besides, you need to ship a whole bunch of fonts and a stylesheet anyway.
Re:KaTeX – The fastest math typesetting library for the web
by mbeex on Sunday October 11, 2020 @10:24AM
(#24746007)
KaTeX has an 'output' option and one of his settings is 'mathml'. You can produce clean MathML this way and even mixed HTML/MathML output (default and what you see in the OP's example) with MathML for accessibility. Problem with the pure approach isn't KaTeX but the browser support.
Re:KaTeX – The fastest math typesetting library for the web
by franga2000 on Sunday October 11, 2020 @08:14AM
(#24745268)
Oh yeah, definitely, I was just responding to the "calling server-side JS" part. Even if the same library was implemented in native code, you still wouldn't want to be calling it inline from a cgi* script.