fred-wang / TeXZilla

LALR Javascript LaTeX-to-MathML converter compatible with Unicode
http://fred-wang.github.io/TeXZilla/
130 stars 21 forks source link

Improve expression grouping using operator precedence #9

Open fred-wang opened 10 years ago

fred-wang commented 10 years ago

See http://www.w3.org/Math/MathML3/chapter3.html#id.3.3.1.3 for a discussion of grouping of sub-expressions.

Expression grouping was removed in 2f3e5f4faaa913842f2fa610b06f55d2f40e027e because it didn't work very well and was a serious performance burden for Jison.

I believe in general, correct operator grouping is not possible because one has to infer some semantics from the TeX source , especially when fences are involved like in y = { [0,1) ; (2,3] }^2.

However, I think it would still be possible to improve the grouping via operator precedence: