mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

AsciiMath to LaTeX conversion has trouble with `\in` operator

Open nathancarter opened this issue 2 years ago • 4 comments

Description

AsciiMath to LaTeX conversion has trouble with the \in operator.

Steps to Reproduce

The following can be done at the JavaScript console in a page with MathLive loaded.

> MathLive.convertAsciiMathToLatex('x in')
'x\\in'
> MathLive.convertAsciiMathToLatex('x in R')
'xinR'
> MathLive.convertAsciiMathToLatex('x in A')
'xinA'
> MathLive.convertAsciiMathToLatex('x !in A')
'x !\\in A'
> MathLive.convertAsciiMathToLatex('x notin A')
'xnotinA'

Actual Behavior

See above.

Expected Behavior

> MathLive.convertAsciiMathToLatex('x in')
'x\\in'
> MathLive.convertAsciiMathToLatex('x in R')
'x\\in R'
> MathLive.convertAsciiMathToLatex('x in A')
'x\\in A'
> MathLive.convertAsciiMathToLatex('x !in A')
'x\\notin A'
> MathLive.convertAsciiMathToLatex('x notin A')
'x\\notin A'

See AsciiMath definitions here.

Environment

I do not know if this is a regression; I just noticed it today.

MathLive version 0.98.5

Operating System macOS 12.4

Browser Verified same behavior on Brave v1.61.109 (on Chromium 120.0.6099.144), Chrome 120.0.6099.129, Firefox 115.0 and 121.0.

nathancarter avatar Dec 28 '23 01:12 nathancarter

This was the first AsciiMath conversion problem I had encountered, and it prompted me to run a larger test on all of the examples on the AsciiMath website linked to above. That test unearthed at least 35 other discrepancies between the official definition of AsciiMath and the version supported in MathLive. How would you like those reported? Just list them all here?

nathancarter avatar Dec 28 '23 13:12 nathancarter

I see from https://github.com/arnog/mathlive/blob/master/src/formats/parse-math-string.ts#L13 that partial support for AsciiMath is a known limitation, not an accidental bug. Is it correct that the code starting here https://github.com/arnog/mathlive/blob/master/src/formats/parse-math-string.ts#L80 is where the partial AsciiMath support is located? If so, would you want PRs for that section of code that extend AsciiMath support?

nathancarter avatar Dec 28 '23 13:12 nathancarter

Rather than upgrade MathLive with full AsciiMath support, I've adopted the following tool (compiles to one JS file) that seems to come indirectly from the official AsciiMath repo. https://github.com/tylerlong/asciimath-to-latex Just posting that here in case it's of any value to MathLive going forward.

nathancarter avatar Dec 28 '23 15:12 nathancarter

Thanks for the info. A PR that improves the ASCIIMath support in MathLive would be welcome.

arnog avatar Dec 28 '23 16:12 arnog