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

[SVG]v3 beta4, "mrow" is represented as "TeXATom" #2193

Closed
itexsolution opened this issue Sep 9, 2019 · 2 comments
Closed

[SVG]v3 beta4, "mrow" is represented as "TeXATom" #2193

itexsolution opened this issue Sep 9, 2019 · 2 comments
Labels
Expected Behavior This is how MathJax works

Comments

@itexsolution
Copy link

itexsolution commented Sep 9, 2019

I'm working on inferring TeX using SVG's mml-node.
The difficulty is that such "mrow" is represented by "TeXAtom".
Look at the following code.

=> TeX

a^{2b}

=>SVG

<g data-mml-node="math">
    <g data-mml-node="msup">
        <g data-mml-node="mi"><use xlink:href="#MJX-TEX-I-61"></use></g>
        <g data-mml-node="TeXAtom" transform="translate(529, 413) scale(0.707)">
            <g data-mml-node="mn"><use xlink:href="#MJX-TEX-N-32"></use></g>
            <g data-mml-node="mi" transform="translate(500, 0)"><use xlink:href="#MJX-TEX-I-62"></use></g>
        </g>
    </g>
</g>

=>mathML

<math>
  <msup>
    <mi>a</mi>
    <mrow>
      <mn>2</mn>
      <mi>b</mi>
    </mrow>
  </msup>
</math>

thank you.

@dpvc
Copy link
Member

dpvc commented Sep 11, 2019

The data-mml-node attributes represent the internal MathML representation used by MathJax. That representation has several extensions to MathML, and one of them is the TeXAtom element. This is used by MathJax to assign TeX's typeset classes (ORD, REL, BIN, OP, OPEN, etc) to compound expressions. In this case, the 2b is marked as an ORD. When output to MathML, this produces an mrow, which has a class assigned to it so that MathJax can reproduce the TeXAtom if that MathML is read back into MathJax's MathML input jax. So the actual MathML generated for the expression (by MathJax) is

<math display="block">
  <msup>
    <mi>a</mi>
    <mrow class="MJX-TeXAtom-ORD">
      <mn>2</mn>
      <mi>b</mi>
    </mrow>
  </msup>
</math>

If you are trying to reconstruct a MathML representation from the SVG output, you would need to use an <mrow> when you see data-mml-node="TeXAtom"; ideal, you would mark it using class="MJX-TeXAtom-ORD" (or whatever class was the one used), but unfortunately, the output is not marked with the tex class. It would be a good idea to include an attribute for that, so I will make a pull request to do so. But the marking as TeXAtom is not an error. It might be considered a misfeature, and perhaps it would be better to use mrow and an additional attribute for the tex class (which could be used to reconstruct the internal MathML+ structure). I will need to give it some thought.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Sep 11, 2019
@itexsolution
Copy link
Author

i understand.
thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants