Finally a long-awaited feature. Works nicely in dark mode too. However, it simply uses MathJax. Also there are some minor annoyances. For example you need to escape the backslashes, so it takes 4 backslashes to make a newline in your matrix. $$\begin{bmatrix} a & b \\\\ c & d\end{bmatrix}$$ I found that the inline math doesn't quite match the font size of the surrounding text too (it's smaller).
In my opinion LaTeX is a poor fit for markdown, although it is the logical—and probably the only—choice. Markdown documents are supposed to be easy to read and quick to type. LaTeX is neither. When I include a matrix in my markdown document I want to type it something like: ## Example Matrix $$$ [a, b; c, d] $$$ Although I realize that we are probably stuck with LaTeX for the foreseeable future as the only way to typ…
Render mathematical expressions in Markdown On GitHub
61–70 of 114 posts
Re: Render mathematical expressions in Markdown On GitHub
#62Re: Render mathematical expressions in Markdown On GitHub
#63Doesn't work on github's builtin wikis
Re: Render mathematical expressions in Markdown On GitHub
#64Earlier quoted context omitted.
If I was building this feature, I'd also pick client side rendering, simply because at GitHub's scale, rendering on the server side will require a bunch of servers, which will need to be managed and looked after. By offloading the rendering to the client, you make use of the spare capacity that exists on most client machines today, with no noticable slowdown for the user (it may even end up doing the "first paint" fa…
Historically client-side rendering has been a big headache. Not sure if it's improved recently, but avid math bloggers and blog readers will remember the problems of the past decade.
Re: Render mathematical expressions in Markdown On GitHub
#65Is the renderer working for this page? Both 'renders' seem blurry on 2021 MBP in Chrome.
Re: Render mathematical expressions in Markdown On GitHub
#66Re: Render mathematical expressions in Markdown On GitHub
#67Nice! 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…
If I was building this feature, I'd also pick client side rendering, simply because at GitHub's scale, rendering on the server side will require a bunch of servers, which will need to be managed and looked after. By offloading the rendering to the client, you make use of the spare capacity that exists on most client machines today, with no noticable slowdown for the user (it may even end up doing the "first paint" fa…
Have you visited math.stackexchange? Pop by their MathJax reference page[0], and observe how long all the mathematical notation takes to render fully—it takes at least six seconds on my recent notebook, plugged in. On my 2018 iPad Pro, it takes well over thirty seconds on the first page load (drops to ~5 s on subsequent visits: there's probably some caching going on).
Here's[1] a benchmark comparing KaTeX (server-side), MathJax 2.7, and MathJax 3.0 (apparently a complete rewrite supporting server-side rendering[2], but it's still noticeably slower than KaTeX).
MathJax is really slow (slower still than LaTeX itself, and that's saying something).
[0]: https://math.meta.stackexchange.com/questions/5020/mathjax-b...
[1]: https://www.intmath.com/cg5/katex-mathjax-comparison.php
[2]: https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.h...
Re: Render mathematical expressions in Markdown On GitHub
#68Earlier quoted context omitted.
You're being modest. This is easily the most performant option... although it means losing interactivity (right clicking equations on GitHub allows copy to clipboard, A11y features, etc). Running the JS client side, like GitHub, means blocking the thread. You're either going to be 1. delaying other JS from running, or 2. rendering late, shifting the layout – which is what GitHub has chosen: https://imgur.com/a/y47haf…
> Figure out viewbox and inline height/width values on the HTML so no layout jank (aka "Cumulative Layout Shift"/CLS) occurs. Unsure if this is possible for inline math. That's a great idea, I should do that. Right now I apply the height and offsets from the SVG file (via vertical-align and height) so that it flows nicely but I should add width too. It is trivially doable since the SVG does contain the width. e.g.
Re: Render mathematical expressions in Markdown On GitHub
#69Earlier quoted context omitted.
If I was building this feature, I'd also pick client side rendering, simply because at GitHub's scale, rendering on the server side will require a bunch of servers, which will need to be managed and looked after. By offloading the rendering to the client, you make use of the spare capacity that exists on most client machines today, with no noticable slowdown for the user (it may even end up doing the "first paint" fa…
> while no noticable slowdown for the user (it may even end up doing the "first paint" faster in the browser if GitHub are careful about their implementation). Have you visited math.stackexchange? Pop by their MathJax reference page[0], and observe how long all the mathematical notation takes to render fully —it takes at least six seconds on my recent notebook, plugged in. On my 2018 iPad Pro, it takes well over thir…
For example, I see no reason why they wouldn't just render the stuff that's in view first, and the rest is rendered incrementally as the user scrolls, or a few seconds after the initial paint.
I take your point that KaTeX is faster in absolute terms, but from a usability point of view, the benefits do not outweigh the costs in my opinion.
Re: Render mathematical expressions in Markdown On GitHub
#70Earlier quoted context omitted.
For pages with lots of mathematics markup, it is far better (in terms of download size) to send the latex markup and the katex library to the browser, and render it there. I tried rendering the mathematics server-side using katex on my own website a while ago, and the div soup generated by katex takes up loads of space. Original page (compressed): 10 kB Page with server-rendered Katex (compressed): 50 kB Katex.js (co…
For my blog (e.g. https://daniel.lawrence.lu/blog/y2021m09d08/ with tons of math), I render the math serverside using MathJax and serve them as SVG images (with alt text for the visually impaired). They get cached too which is nice especially since many symbols are duplicated. Seems fast enough for me.