3 ms·
The author of ConTeXt (a TeX format similar to LaTeX) has some interesting comments on AsciiMath [0] [1]. Its space handling looks especially problematic; the e
by gucci-on-fleek 11mo ago
The author of ConTeXt (a TeX format similar to LaTeX) has some interesting comments on AsciiMath [0] [1]. Its space handling looks especially problematic; the example given in [0]
o ox x = xo
a ax x = xa
ooxx=xo
aaxx=xa
ac+sinx+xsqrtx+sinsqrtx+sinsqrt(x)
produces the following output
o ⊗ x = x o
a a x x = x a
∞ × = x o
a a × = x a
a c + sin x + x √x + sin √x + sin √x
Its handling of commas looks even worse, but it's tricky to demonstrate that in plain text.
[0]: https://tug.org/TUGboat/tb36-2/tb113hagen.pdf#page=3 https://tug.org/TUGboat/tb36-2/tb113hagen.pdf#page=3
[1]: https://github.com/contextgarden/context/blob/e9bd55ec/tex/context/modules/mkxl/x-asciimath.mkxl#L16-L128 https://github.com/contextgarden/context/blob/e9bd55ec/tex/c...
- emil-lp 11mo agoWhy is the space handling "especially problematic"? It has significant whitespace, that shouldn't be problematic, should it?
- gucci-on-fleek 11mo ago> It has significant whitespace, that shouldn't be problematic, should it? Significant whitespace is totally fine, but whitespace that is sometimes significant and sometimes not isn't. In the examples above, "sinsqrtx" produces the same output as "sin sqrt x", but "ooxx", "o ox x", and "o o x x" all produce completely different output.
- emil-lp 11mo agoI don't buy this argument. Sometimes something has a unique way of being interpreted, then you don't need spaces. It's the same with math and code. 2x+3=(2x)+3 != 2(x+3) Parentheses are also "sometimes significant and sometimes not".
- runarberg 11mo agoThe problem is with the stream of alphanumeric symbols. Most languages treat sqrtx as a single token, but asciimath treats it as two (sqrt and x) if you put a symbol in between them (sqrt+x) most languages treats it as three tokens (sqrt, +, x) and asciimath is no different. asciimath’s choice here is to make whitespace (sometimes) optional between two subsequent alphanumeric tokens, and it is a rather odd choice. I‘m not sure which other language (markup or otherwise) does it this way.
- sevensor 11mo ago> the only robust way to edit \ASCIIMATH\ is to use a \WYSIWYG\ editor and hope that the parser doesn't change ever. Ouch. I wrote a couple of parsers when I was young and foolish without trying to specify the grammar, and it’s a good thing they didn’t get popular, because every bugfix changed the syntax and broke texts that had been working before.
- runarberg 11mo agoShameless plug (again): This is one of the issues I addressed when I wrote the competing mathup library. alphanumeric tokens MUST be separated from each other with a symbol or whitespace. ooxx => ooxx oo xx => ∞× sqrtx => sqrtx sqrt x => √x sqrt(x) => √x The way I deal with commas is that I always treat commas as an operator (or a seperator in group context), unless the author configures comma to be the decimal mark (and I only allow exactly one decimal mark for each parse run). https://mathup.xyz https://mathup.xyz