News for hackers. Stuff that matters.
Re:KaTeX – The fastest math typesetting library for the web by snicker7 on Saturday October 10, 2020 @11:24PM (#24743521)
KaTeX is great, but I long for a system that:

1. Can be rendered server-side without a heavy runtime (ideally written in C/C++/Rust/Whatever instead of JS).

2. Has a well defined output AST, so that the output can be manipulated (e.g. realtime visual equation editing).

3. Is accessible to the visually impared.

Actually, we have such a system: MathML. And its a W3C standard to boot. The only reason why we have to rely on slow JS hacks like KaTeX and MathJax is because of Chrome. Google hates disabled people.

Re:KaTeX – The fastest math typesetting library for the web by foepys on Sunday October 11, 2020 @02:02AM (#24744048)
I don't know if I'm reading [1] correctly but it appears that Google is finally working on implementing MathML in Chromium. There have been multiple commits and updates to this bug in 2020, especially in September.

Edit: It's not being implemented by Google. It's a sponsored effort because Google couldn't be bothered. [2]

1: https://bugs.chromium.org/p/chromium/issues/detail?id=6606

2: https://mathml.igalia.com

Re:KaTeX – The fastest math typesetting library for the web by bjoli on Sunday October 11, 2020 @06:55AM (#24744926)
Igalia seems like such a great company. They are doing lots of important and exciting things in open source. Sure, they get paid for it and all that, but it seems like such a cool idea. I am glad it seems to work for them
Re:KaTeX – The fastest math typesetting library for the web by gostsamo on Sunday October 11, 2020 @12:16AM (#24743675)
The bad accessibility of math notation and math content is one of the main reasons there are very few visually impaired people in STEM, one of the main reasons why I'm doing code and not physics, and why Firefox is given as the accessibility default in web.
Re:KaTeX – The fastest math typesetting library for the web by xiphias2 on Sunday October 11, 2020 @05:01AM (#24744580)
Actually often I wish that AI papers contained code instead of math so that it's clearer how it can be implemented, and how the variables are used. It would make the papers a bit longer, but implementations easier to understand.
Re:KaTeX – The fastest math typesetting library for the web by gspr on Sunday October 11, 2020 @07:37AM (#24745104)
> Actually often I wish that AI papers contained code instead of math so that it's clearer how it can be implemented

That's insanity. Sure, code is a nice addition, but it does not convey the same information as the math does.

It's akin to asking to replace an engineer's design of a bridge with a scale model.

Re:KaTeX – The fastest math typesetting library for the web by c0nfused on Sunday October 11, 2020 @08:53AM (#24745444)
I think this is more akin to construction workers asking for blueprints rather than cad models.

As someone who hasn't actively done formal math in a couple of decades the slog of relearning syntax to read papers about code can be off putting. I understand that this makes me a barbarian. However code is really the lingua franca we use as an industry but in papers it is treated exactly as you say a nice addition.

Re:KaTeX – The fastest math typesetting library for the web by gspr on Sunday October 11, 2020 @10:16AM (#24745945)
> I think this is more akin to construction workers asking for blueprints rather than cad models.

No, because those aim to express the same thing, albeit with different limitations and practical considerations. Code and math are entirely separate things.

> As someone who hasn't actively done formal math in a couple of decades the slog of relearning syntax to read papers about code can be off putting.

Surely the syntax is an incredibly minor part of it all?

> However code is really the lingua franca we use as an industry but in papers it is treated exactly as you say a nice addition.

Code is an implementation detail. Papers express ideas, not implementations.

Re:KaTeX – The fastest math typesetting library for the web by arthur2e5 on Sunday October 11, 2020 @10:10AM (#24745893)
Not quite the same field, but see https://news.ycombinator.com/item?id=24649992 for an article about PLT (programming language theory) notation.
Re:KaTeX – The fastest math typesetting library for the web by Loic on Sunday October 11, 2020 @04:08AM (#24744400)
Working daily with a blind scientist, I am translating the equations from old papers without good OCR in Fortran to discuss them. I haven't found a better way, but we would definitely appreciate more accessible content.
Re:KaTeX – The fastest math typesetting library for the web by neolog on Sunday October 11, 2020 @06:11AM (#24744794)
You're translating into fortran? Why?
Re:KaTeX – The fastest math typesetting library for the web by Loic on Sunday October 11, 2020 @07:41AM (#24745118)
Because Fortran is FORmula TRANslator and it is very easy to express complex equations with it. It the lingua franca of scientific computing.
Re:KaTeX – The fastest math typesetting library for the web by neolog on Sunday October 11, 2020 @11:50PM (#24751214)
TIL. I'm curious what Fortran buys you over, say, Julia.
Re:KaTeX – The fastest math typesetting library for the web by Loic on Monday October 12, 2020 @01:53PM (#24757244)
We simply master Fortran because of all the number crunching we are doing, nothing more.
Re:KaTeX – The fastest math typesetting library for the web by TheRealKing on Monday October 12, 2020 @03:32PM (#24758470)
because it is powerful, fast, simple, object oriented, while being natively parallel, on both shared and distributed architecture.
Re:KaTeX – The fastest math typesetting library for the web by hyiltiz on Sunday October 11, 2020 @02:21AM (#24744107)
Would mathematical[0] satisfy at least the first two requirement? I just found about it from the MathJax post today.

[0] https://github.com/gjtorikian/mathematical

Re:KaTeX – The fastest math typesetting library for the web by euske on Sunday October 11, 2020 @09:54AM (#24745774)
FYI, LaTeX notation is used by many blind people to express math ideas even if they don't actually use LaTeX for typesetting. (I personally know two programmers, one math teacher and one scientist who are using it with a braille display on daily basis.) So it's not totally anti-accessibility.
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:

    <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi>g</mi><mi>a</mi></msup><mspace></mspace><mspace width="0.6666666666666666em"></mspace><mrow><mi mathvariant="normal">m</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">d</mi></mrow><mtext> </mtext><mtext> </mtext><mi>p</mi><mo>=</mo><mi>A</mi></mrow><annotation encoding="application/x-tex">g^a\mod p=A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.858832em;vertical-align:-0.19444em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.664392em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">a</span></span></span></span></span></span></span></span><span class="mspace allowbreak"></span><span class="mspace" style="margin-right:0.6666666666666666em;"></span></span><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">m</span><span class="mord mathrm">o</span><span class="mord mathrm">d</span></span></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mspace" style="margin-right:0.16666666666666666em;"></span><span class="mord mathnormal">p</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:0.68333em;vertical-align:0em;"></span><span class="mord mathnormal">A</span></span></span></span>
This is:

    g^k\equiv a\pmod{p}
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.
Re:KaTeX – The fastest math typesetting library for the web by wsimson on Monday October 12, 2020 @04:09AM (#24752389)
I think this might be what you're looking for: https://github.com/cqql/pelican-katex