Hacker News new | ask | show | jobs
by yig 1245 days ago
Author here. Ask me anything.
3 comments

Any particular reason the Mathjax is gimped?

When I bring up the context menu for the compiled result on <https://iheartla.github.io/iheartla/>, my preferred renderer MathML is missing. I noticed right away that something is wrong because the result objectively looks bad, the bracket parts are of differing width, various surrounding elements do not align with the contained content, and also the text has terrible kerning. <https://files.catbox.moe/wp2r0t.webp>

Compare with e.g. <https://codimd.web.cern.ch/features#MathJax> which has much more options to choose from as renderer and its output as MathML is exceedingly pleasing to look at.

We're using MathJax 3.x, which dropped support for inserting MathML into the DOM due to uneven browser support [0]. The example you linked uses MathJax 2.x.

[0]: https://docs.mathjax.org/en/latest/output/mathml.html

Thanks for taking the time to investigate and explain the problem. I understand you're not at fault but the maintainers upstream, yet I can't help but be disappointed. Removing MathML doesn't help anyone, the user just has a worse experience; it's caused by the same brainrot as with Gnome.
Is this example under the Language Reference link correct? It seems to be missing a closing brace.

  A_ij = { 1 if (i,j) ∈ E
           0 otherwise
  where
  A ∈ ℝ^(n × n)
  E ∈ { ℤ × ℤ }
  n ∈ ℤ
It's not common to close that brace when writing math. (I've not seen it.)
Ah, right, I see now what is is, I was confused.

Another thing I find confusing are the braces around ℤ × ℤ. They seem to be unnecessary (it wouldn’t make much sense for ∈ to have higher precedence than ×), and/or would imply a singleton set containing the set ℤ × ℤ as its only element.

I wonder whether adding a brace for each row would clarify the notation, by more closely resembling a single multi-line brace:

  A_ij = { 1 if (i,j) ∈ E
         { 0 otherwise
  where
  A ∈ ℝ^(n × n)
  E ∈ { ℤ × ℤ }
  n ∈ ℤ
I like this. I created a GitHub issue: https://github.com/iheartla/iheartla/issues/138
If they want it to look like actual math notation, they might as well:

  A_ij = ⎰ 1 if (i,j) ∈ E
         ⎱ 0 otherwise
  where
  A ∈ ℝ^(n × n)
  E ∈ { ℤ × ℤ }
  n ∈ ℤ
Unicode actually has semantic symbols that could be used for a nicer 2D monospaced layout here, such as ⎧ ⎪ ⎨ ⎩ ( (LEFT CURLY BRACKET UPPER HOOK, MIDDLE PIECE, LOWER HOOK, and CURLY BRACKET EXTENSION). With more conditional rows, you could use these. One downside is that you would have to do a 2D parse, since the = wouldn't be on the first line. We've been loath to go there. It also seems painful as a user to have to type all the right bracket symbols in all the right places.

We do support the Unicode ⎡|⎦ symbols for matrices. The grammar is that a matrix starts with either [ or ⎡ and ends with either ] or ⎦. Rows can be optionally surrounded by |. I find this too cumbersome to use myself.

Why not use the haskell guard syntax?

  A_ij = | 1 if (i,j) ∈ E
         | 0 otherwise
  where
  A ∈ ℝ^(n × n)
  E ∈ { ℤ × ℤ }
  n ∈ ℤ
I (speaking as a designer of I Heart LA empathizing with a user) wouldn't have thought to use that character as an approximation of {.
It must require special editors or plugins. I have no idea how to type all those "chalkboard" math symbols.
The docs [1] include a table of symbols you can copy/pate from, and lists shortcuts that will be expanded by the IDE/online editor [2] - these mostly look like the LaTeX commands for the symbols (some are more concise, like \R and \Z as shortucts for \mathbb{R} and \mathbb{Z}).

It would be useful if there was something like a help button in the IDE that opened this table in a modal, rather than just a link.

[1]: https://github.com/iheartla/iheartla/wiki/Keywords-And-Speci...

[2]: https://iheartla.github.io/iheartla/

I foresee a latex like language that can compile to iheartla