Live data from Hacker News

Render mathematical expressions in Markdown On GitHub

github.blog

111–114 of 114 posts

Re: Render mathematical expressions in Markdown On GitHub

#111
post #100

Earlier quoted context omitted.

Everything else on a web page is rendered client side (HTML is just text…) so client side rendering makes sense to me here too.

Rendering HTML doesn't require a huge JS library.

HTML requires a huge browser binary though, and the JS library should be cached on first visit to a page that uses it. Seems the right trade off to me to have a one off download for this use case (i.e. potentially viewing many pages on the same site, as opposed to a small number of pre rendered pages) then only need to transfer plain text which is already in the markdown source (so is needed if you’re going to edit or view the raw MD anyway).

Re: Render mathematical expressions in Markdown On GitHub

#112
post #45

Earlier quoted context omitted.

I used to think KaTeX was far superior to MathJax but now I'm not so sure. I made https://mk12.github.io/web-math-demo/ to compare them and other things. They're definitely superior to browser MathML rendering today, which is nonexistent in Chrome (though see https://mathml.igalia.com/ ), quite bad in Safari, and OK in Firefox. It's true pre-rendering KaTeX produces a lot of markup, but it compresses very well so I d…

> https://github.com/KaTeX/KaTeX/issues/3400 has gone unfixed for a long time. I don't think I'd qualify an issue from the end of last year as "unfixed for a long time".

Sorry I posted the wrong issue, it’s actually a duplicate of https://github.com/KaTeX/KaTeX/issues/3168 which was filed last August. I guess it’s not that long, but it was annoying for my use of KaTeX on https://mitchellkember.com/notes4u where I see it frequently. For example it affects \left\lvert\vec{b}\right\rvert which is a pretty simple piece of TeX I’d expect to render fine.

Re: Render mathematical expressions in Markdown On GitHub

#113
post #8

Nice! A welcome addition! Too bad they're not using KaTeX [0] instead. It renders the maths server-side, so there's no runtime needed. An additional bonus is that the resulting math is copy-pasteable, which in the case of disply math might not be that useful (since most equations are to complex to be meaningfully copy-pasted with unicode), but it helps from inline math dissappearing when copy pasting texts. But, that…

The last I knew, KaTeX had issues with accessibility. But honestly it is probably just best to ship raw MathML, translated from LaTeX on the server, and use MathJax as a polyfill for Chrome and Edge users. That way you get extremely fast rendering in Safari and Firefox without any extra javascript, and eventually Chrome will catch up.

I wouldn’t recommend relying on Safari MathML rendering today for anything but very basic equations. Firefox is a lot better, but still not quite at MathJax quality. I made a demo here https://mk12.github.io/web-math-demo/ that lets you compare them. Also if you edit the MathML markup box, it will render directly from that, just like the poly fill (sometimes the layout shifts slightly when switching from TeX -> MathJax HTML+CSS to TeX -> MathML -> MathJax HTML+CSS).

Re: Render mathematical expressions in Markdown On GitHub

#114
post #113

Earlier quoted context omitted.

The last I knew, KaTeX had issues with accessibility. But honestly it is probably just best to ship raw MathML, translated from LaTeX on the server, and use MathJax as a polyfill for Chrome and Edge users. That way you get extremely fast rendering in Safari and Firefox without any extra javascript, and eventually Chrome will catch up.

I wouldn’t recommend relying on Safari MathML rendering today for anything but very basic equations. Firefox is a lot better, but still not quite at MathJax quality. I made a demo here https://mk12.github.io/web-math-demo/ that lets you compare them. Also if you edit the MathML markup box, it will render directly from that, just like the poly fill (sometimes the layout shifts slightly when switching from TeX -> MathJ…

Nice demo. I don’t have access to a mac so I can’t see this in Safari, but using Firefox I can immediately spot there are some kerning mistakes in the MathML rendering which are not present in MathJax rendering.

However, isn’t that just the fact the the default math font (DejaVu Math TeX Gyre in Firefox i-on Ubuntu) is not good enough? I use Libertinus Math in my own little demo page (https://runarberg.github.io/mathup/) and it looks just fine (IMO). The only think to note is that TeX Gyre is so pervasive (as it is the default [only?] MathJax font) that it takes a bit getting used to other math fonts on the web.

For example here is the Iglalia example from your demo page displayed with Libertinus Math in Firfox (https://imgur.com/q3QuJOA). The same example has some issues in your demo page with DejaVu Math TeX Gyre

Post reply on HN