asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 16 forks source link

Percent sign should be an operator (<mo>) #58

Closed skalee closed 3 years ago

skalee commented 3 years ago

Problem description

Given example:

AsciiMath.parse("40%").to_mathml

Expected result:

<math><mn>40</mn><mo>%</mo></math>

Actual result:

<math><mn>40</mn><mi>%</mi></math>

That is it includes <mi>%</mi> instead of <mo>%</mo>.

Rationale

  1. It is a suffix operator or part of number notation, but certainly not an identifier.
  2. https://github.com/asciimath/asciimathml converts percent signs to <mo>%</mo>.

Can you provide a fix?

I think so.

pepijnve commented 3 years ago

I found the missing bit of logic in the asciimath.js implementation at https://github.com/asciimath/asciimathml/blob/master/ASCIIMathML.js#L605 tagst = (("A">st || st>"Z") && ("a">st || st>"z")?"mo":"mi");

This implementation doesn't have this heuristic in place. Should be easy enough to fix.