Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Math Processing Error] with \mmlToken{annotation} #376

Closed
fred-wang opened this issue Jan 14, 2013 · 8 comments

Comments

Projects
None yet
2 participants
@fred-wang
Copy link
Contributor

commented Jan 14, 2013

testcase:

\mmlToken{annotation}{blah blah}

The error message is the same as issue #363, although I'm not sure if it is the same or a separate issue. Specifying a default mathvariant on MathJax.ElementJax.mml.annotation does not seem to help.

@fred-wang

This comment has been minimized.

Copy link
Contributor Author

commented Feb 6, 2013

The fix to issue 363 does not solve this bug. The error happens at the same place but the error I see is that MML.mbase calls the toHTML function with only one argument. But the mchar.toHTML is actually called and this one needs a mathvariant. Checking whether variant is undefined might help, but perhaps the appropriate fix should be elsewhere.

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 7, 2013

The real issue is that mmlToken shouldn't be able to create an <annotation> element. It is not a token element, and it is only allowed within a <semantics> element anyway, and there isn't any way to make that within TeX.

There is a flag in the MML.annotation object that marks it as a token element, but I'm no longer sure why. I have a vague recollection that it needed to be treated as a token element for some reason, but can't remember exactly why. Maybe the line breaking algorithm. Searching for isToken may help jog my memory...

In any case, it should probably not be marked isToken, and whatever the need was for that should be handled another way. That will prevent \mmToken{} from being able to create it.

@fred-wang

This comment has been minimized.

Copy link
Contributor Author

commented Mar 20, 2013

The isToken flag has been there since the first implementation and I don't think linebreaking was available at that time: http://mathjax.svn.sourceforge.net/viewvc/mathjax?view=revision&revision=256

@dpvc

This comment has been minimized.

Copy link
Member

commented Mar 20, 2013

It may be that annotation was called a token element in earlier drafts of the MathML specification (which is what I was using when I wrote the initial element jax implementation), and that that was taken out later. That's the only other thing I can think of. But it currently isn't considered a token element (at least it doesn't seem to be listed there now).

@fred-wang

This comment has been minimized.

Copy link
Contributor Author

commented Mar 20, 2013

So here are the places where isToken is used:

find MathJax/unpacked -name *.js | xargs grep -n isToken | grep -v "isToken:"
MathJax/unpacked/jax/element/mml/jax.js:260:          {item = (this.isToken ? MML.chars(item) : MML.mtext(item))}
MathJax/unpacked/jax/element/mml/jax.js:370:      if (this.isToken || this.linebreakContainer) {return false}
MathJax/unpacked/jax/output/HTML-CSS/jax.js:1693:     if (this.isToken) {lW = bbox.lw; rW = bbox.rw - bbox.w}
MathJax/unpacked/jax/output/HTML-CSS/jax.js:1786:   if (this.isToken) {scale *= HTMLCSS.length2em(values.mathsize)}
MathJax/unpacked/jax/output/HTML-CSS/jax.js:2023:        if (!parent.isToken) {return ""} else {return parent.data.join("")}
MathJax/unpacked/jax/output/HTML-CSS/autoload/maction.js:98:        if (this.data[1] && this.data[1].isToken) {
MathJax/unpacked/jax/output/HTML-CSS/autoload/maction.js:132:        ((this.data[1] && this.data[1].isToken) ?
MathJax/unpacked/jax/output/HTML-CSS/autoload/multiline.js:139:      if (this.isToken) {return false}  // FIXME: handle breaking of token elements
MathJax/unpacked/jax/output/SVG/jax.js:1225:    if (this.isToken) {scale *= SVG.length2em(values.mathsize)/1000}
MathJax/unpacked/jax/output/SVG/jax.js:1354:        if (!parent.isToken) {return ""} else {return parent.data.join("")}
MathJax/unpacked/jax/output/SVG/autoload/maction.js:113:        ((this.data[1] && this.data[1].isToken) ?
MathJax/unpacked/jax/output/SVG/autoload/multiline.js:142:      if (this.isToken) {return false}  // FIXME: handle breaking of token elements
MathJax/unpacked/jax/input/MathML/jax.js:147:          if (mml.isToken && !mml.mmlSelfClosing) {
MathJax/unpacked/jax/input/TeX/jax.js:1414:      if (!MML[type] || !MML[type].prototype.isToken) {TEX.Error(type+" is not a token element")}
MathJax/unpacked/jax/input/TeX/jax.js:2077:          if (!mml.data[i].isToken) {this.combineRelations(mml.data[i])}
MathJax/unpacked/extensions/toMathML.js:40:      var data = []; var SPACE = (this.isToken ? "" : space+(inferred ? "" : "  "));
MathJax/unpacked/extensions/toMathML.js:43:          else if (!this.isToken) {data.push(SPACE+"")}
MathJax/unpacked/extensions/toMathML.js:45:      if (this.isToken) {return space + "<"+tag+attr+">"+data.join("")+""}

@ghost ghost assigned dpvc Apr 16, 2013

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 20, 2014

Davide P. Cervone
Make annotation NOT be a token element, by adding a new isChars flag …
…to force its contents to be a chars node rather than an mtext node (which is why it was labelled isToken originally). Resolves issue mathjax#376.
@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 20, 2014

OK, I found out why <annotation> elements were marked as token elements: it is so that the text content will be added as a text node rather than throwing an error about badly placed text nodes. I have resolved the issue, and so now \mmlToken can't produce an <annotation> element. (You can still produce the error by putting <annotation> elements outside of a <semantics> element, however, but that is invalid MathML.)

@dpvc dpvc added Ready for Review and removed Investigate labels Feb 20, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 21, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 21, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 21, 2014

=> Merged.

@dpvc dpvc closed this Feb 21, 2014

dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Apr 21, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 21, 2014

=> In Test Suite

LaTeXToMathML/non-standard/issue376.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.