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

ASCIIMath parsing: {: :} within {: :} #1245

Closed karbuncle closed 8 years ago

karbuncle commented 9 years ago

It seems to cause Math processing error whenever the pair of brackets {: :} is wrapped in another pair of brackets {: :}, and is the only thing in that bracket.

Examples:

not ok {: {::} :}
not ok {: {:     :}    :}

ok {: {:  something :} :}
ok {: {:  :} something :}
pkra commented 9 years ago

Thanks for reporting this. This does not look like an upstream asciimath issue.

dpvc commented 9 years ago

Actually, I think it is an upstream bug. The error is being caught at line 1064, where they are looking up newFrag.childNodes[len-1].lastChild.firstChild.nodeValue. Here, newFrag is going to form the <mrow> for the outer {: ... :}, and it has len equal to 1. It's one child is the <mrow> from the inner {: :}, which is empty, so has no children. So newFrag.childNodes[0] is the empty <mrow>, and newFrag.childNodes[0].lastChild is null (correctly), so when firstChild is requested of that, it is an error.

The reason it works for {: {: a :} :} is that the inner <mrow> now contains <mi>a</mi> and so newFrag.childNodes[len-1].lastChild is the <mi> and newFrag.childNodes[len-1].lastChild.firstChild is the text node containing a, and the nodeValue will be "a", so all is well.

The reason {: {: :} a :} works (but {: a {: :} :} doesn't) is that this code is only reached if newFrag.childNodes[len-1].nodeName == "mrow", but in this case, newFrag has len equal to 2, and so newFrag.childNodes[len-1] is the <mi>a</mi> not the empty <mrow>, and the condition isn't met, so the code isn't run.

pkra commented 9 years ago

Thanks, @dpvc -- I'll file a bug upstream at https://github.com/asciimath/asciimathml/issues/40

pkra commented 9 years ago

Fixed upstream.

@dpvc do we add this to the 2.6 milestone? I'm ok either way.

dpvc commented 8 years ago

@pkra, I think we should update the AsciiMath input jax to the current state of asciimathml at the end of the beta test phase. We don't really have anything in the test suite to test AscaiiMath ourselves, so I don't think it matters how late that is done.

pkra commented 8 years ago

:+1:

pkra commented 8 years ago

This was fixed in 2.6 (via the upstream issue).