Live data from Hacker News

Render mathematical expressions in Markdown On GitHub

github.blog

21–30 of 114 posts

Re: Render mathematical expressions in Markdown On GitHub

#21
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…

I'm so happy that I can just paste my definitions from latex preamble into a paragraph to include all the calitographic symbols and other conveniences with Mathjax. As far as I know, I can't easily do it without adapting to Katex-specific syntax.

Re: Render mathematical expressions in Markdown On GitHub

#22
post #7

> **The Cauchy-Schwarz Inequality** > $$left( \sum_{k=1}^n a_k b_k \right)^2 \leq left( \sum_{k=1}^n a_k^2 \right) left( \sum_{k=1}^n b_k^2 \right)$$ I wonder why their syntax highlighting on this example highlights `left` but not `right`? (I can't seem to reproduce it here, since the HN parser tries to outsmart me.)

The reason is that their blog rendering auto-identifies that code block as SCSS and treats “left” as an attribute. Which is strange, since I cannot find something for “left” that is not defined for “right”.

For example, I cannot find a “left” attribute here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes

Re: Render mathematical expressions in Markdown On GitHub

#23
post #22
post #7

> **The Cauchy-Schwarz Inequality** > $$left( \sum_{k=1}^n a_k b_k \right)^2 \leq left( \sum_{k=1}^n a_k^2 \right) left( \sum_{k=1}^n b_k^2 \right)$$ I wonder why their syntax highlighting on this example highlights `left` but not `right`? (I can't seem to reproduce it here, since the HN parser tries to outsmart me.)

The reason is that their blog rendering auto-identifies that code block as SCSS and treats “left” as an attribute. Which is strange, since I cannot find something for “left” that is not defined for “right”. For example, I cannot find a “left” attribute here: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes

Some more details. They are using Highlight.js, and `attribute` is what is applied to (S)CSS properties too. But both `left` and `right` are valid properties. What I think is that `\r` is treated as the special Carriage Return character and therefore doesn’t allow `right` to be identified.

Re: Render mathematical expressions in Markdown On GitHub

#24
This is cute but it seems that expressions spanning multiple lines are not rendered

OK:

$$\|\vec{x} - \vec{p}_c\| = v(t_c-t_0)$$

--

NOT OK:

$$

\|\vec{x} - \vec{p}_c\|

= v(t_c-t_0)

$$

This makes larger latex expressions pretty impractical e.g. https://github.com/jurasofish/multilateration/blob/master/re...

Re: Render mathematical expressions in Markdown On GitHub

#27

Big picture it's interesting how GitHub + Markdown is basically becoming a major content publishing product. Albeit for a technical niche market. Of course I'm not saying this is GitHub's main goal. More like a P1. Instant publishing, diagrams, and now math expressions.

Github becomes a favorite option for research and academic people to work and collaborate their projects their. That is a reasonable move from github to make it more suitable for them. I know my group and several others are relying more and more on github as git host with other products used for collaboration.

Re: Render mathematical expressions in Markdown On GitHub

#29
post #13
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…

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.

Re: Render mathematical expressions in Markdown On GitHub

#30

Math doesn't render inside a bullet list item. I don't know how to file an issue against Github itself, somewhat ironically.

(I work at GitHub.) We've started using our Discussions product for feedback. You can post a discussion here:

https://github.com/github/feedback/discussions/categories/ge...

Post reply on HN