News for hackers. Stuff that matters.
Re:Math on GitHub: The Good, the Bad and the Ugly by runarberg on Saturday May 21, 2022 @10:19AM (#31458160)
The author fails to mention MathML as an alternative choice. The options aren’t just MathJax and KaTeX, but also raw MathML. MathML gives you extremely fast rendering, more font choices, copy-paste, a11y, etc. out of the box. The only downside is that Chrome is lagging behind in implementation, for that they could use MathJaX as a polyfill—as MathJax understands and is able to transform MathML—and allow Safari and Firefox users the benefits of using browsers that can render math natively.
Re:Math on GitHub: The Good, the Bad and the Ugly by forgotpwd16 on Saturday May 21, 2022 @11:54AM (#31458956)
It isn't mentioned because because they aren't really the same thing. MathML is a web native math markup language and being XML is meant to be written by machines rather humans[^0]. TeX is a markup language that MathJax and KaTeX render to a web suitable format but meant to be written by humans[^0]. Both MathJax and KaTeX have support for rendering TeX to MathML.

[^0]: Compare Pythagorean theorem written in MathML and TeX.

MathML:

  <math>
  <mrow><msup><mi>  a </mi><mn>2</mn>
  </msup><mo>+ </mo><msup><mi>b </mi><mn>2</mn>
  </msup><mo>= </mo><msup><mi>c </mi><mn>2</mn>
  </msup></mrow></math>.
TeX:

  $$
  a^2 + b^2 = c^2
  $$
I'll be surprised if someone preferred to write the first rather the second.
Re:Math on GitHub: The Good, the Bad and the Ugly by runarberg on Saturday May 21, 2022 @12:27PM (#31459269)
Nobody writes the first example by hand[^1]. They write it in TeX (or some other easy to write dialect, or use a graphic WYSIWYG editor) and then use a tool to translate it to MathML.

What I’m advocating here is that GitHub translates TeX to MathML on their servers and serve us the MathML, as opposed to leaving the TeX as is and ship a JavaScript library to render it after it reaches our browsers. Chrome users won’t see a difference as they don’t support MathML, so they need MathJax as a polyfill. But there is a world of difference for us Firefox and Safari users.

Another benefit is that you could allow us to include the pure MathML (by hand or authored by some other tool) if we preferred that.

^1: and if they did write it by hand it would be written as

    <math display="block">
      <msup>
        <mi>a</mi>
        <mn>2</mn>
      </msup>
      <mo>+</mo>
      <msup>
        <mi>b</mi>
        <mn>2</mn>
      </msup>
      <mo>=</mo>
      <msup>
        <mi>c</mi>
        <mn>2</mn>
      </msup>
    </math>
Re:Math on GitHub: The Good, the Bad and the Ugly by forgotpwd16 on Saturday May 21, 2022 @02:41PM (#31460592)
>What I’m advocating here is that GitHub translates TeX to MathML on their servers and serve us the MathML

I see. What confused me was the "options aren’t just MathJax and KaTeX, but also raw MathML" since those tools can be used server-side and they output some HTML or MathML or images. MathJax moreover besides TeX also takes MathML and AsciiMath input.

>Another benefit is that you could allow us to include the pure MathML

I guess they went with what most people work with since rendering TeX in Markdown complements their Jupyter notebook rendering.

>and if they did write it by hand it would be written as

Maybe. I copied my example from MDN docs git repo.

Re:Math on GitHub: The Good, the Bad and the Ugly by nschloe on Monday May 23, 2022 @04:11AM (#31476449)
Author here. Thanks for the comment!

The main problems pointed out in the blog post are problems in _parsing_ the Markdown+TeX pages. The output could be MathML indeed, but this is an issue they could always fix later.