MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

MathMLVisitor should turn <texatom> into <mrow>

Open hbghlyj opened this issue 3 years ago • 2 comments

tex = '{1}';
options = {end:MathJax._.core.MathItem.STATE.CONVERT,format:"TeX"};
root = MathJax.startup.document.convert(tex,options);
visitor = new MathJax._.core.MmlTree.MathMLVisitor.MathMLVisitor();
console.log(visitor.visitTree(root,document).outerHTML);

Output

<math display="block"><texatom><mn>1</mn></texatom></math>

I notice that when SerializedMmlVisitor visits a TeXAtom node, it is turned into a mrow with the appropriate TeX class indicator. But MathMLVisitor doesn't do this conversion.

hbghlyj avatar Sep 01 '22 10:09 hbghlyj

The MathML visitor isn't used in MathJax anywhere, so it doesn't get much attention. You are right, though, it should do a better job with TeXAtom nodes. I'll see what I can do.

dpvc avatar Sep 04 '22 13:09 dpvc

I've made a PR that resolves the issue (by refactoring the SerializedMmlVisitor code so that can be used by MathMLVisitor as well).

dpvc avatar Sep 15 '22 21:09 dpvc