mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.23k stars 1.16k forks source link

Typst support? #3104

Open kwinso opened 1 year ago

kwinso commented 1 year ago

Is your feature request related to a problem? Please describe. Typst math syntax is pretty neat and easy to learn, which makes it superior to LaTeX in a lot of cases (personally, I'm using it to make notes at university). It would be greate to have support for this for mathjax.

Describe the solution you'd like Make it a part of the default suite (which is LaTeX, ASCIIMath and MathML) or at least make it somewhat pluggable

Describe alternatives you've considered N/A

Additional context Typst math syntax: https://typst.app/docs/reference/math/ Possible source of inspiration: https://github.com/xushengfeng/xmmath (although the code is very unreadable)

dpvc commented 1 year ago

Typst seems like an interesting project, and one that includes lots more than just math. For example, it has its own programming language, and allows you to defined variables and such that can be plugged into the mathematical expressions, and that is beyond the scope of MathJax, in general.

MathJax already includes a simplified notation, AsciiMath (as you point out), and a number of the examples in the documentation you link to work very similarly in AsciiMath. Typst does have some nice features, like the alignment syntax, that are harder in AsciiMath.

I took a look at the source code for Typst, but was not able to make much sense of its structure from my cursory exploration. I wasn't able to identify the code used to parse the mathematics, or what internal structure they were using for the mathematics, or what format is used in the final output. It looks like they are including the fonts as part of the repository, which suggests they are doing their own layout rather than using something like MathML in the browser, for example. That makes things harder, as MathJax's internal format is based on MathML, and one of the reasons AsciiMath could be made an input jax for MathJax so easily is that it converts its input to MathML. Without that, one would likely have to reimplement a parser for the Typst math syntax that generates MathML. Your xmmath link is such a parser, and that might be able to be used as a basis for a MathJax input jax, but since it is separate from the Typst project, keeping it in sync would be a maintenance issue (even keeping the AsciiMath input jax up to date for MathJax is not straight-forward).

With the limited development resources that we have, it is unlikely that we will pursue a Typst input jax at this time, though if someone wanted to sponsor the development one one, that could make a difference. Alternatively, a community member could contribute such an input jax (that's how AsciiMath initially became included in MathJax).