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

Update TeXAtom to save the texClass in the property list, so it appears in MathML output. (mathjax/MathJax#2585) #569

Merged
merged 2 commits into from
Mar 8, 2021

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Dec 16, 2020

This PR adjusts the TeXAtom node to save the node's TeX class in the property list so that it will be included in the data-mjx-texclass attribute when serialized MathML is generated, even if the TeX class is just the default ORD class. This allows the serialized MathML to preserve the TeXAtom even when the property was not set explicitly.

For example, f{\left(x\right)} currently produces

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>f</mi>
  <mrow>
    <mrow data-mjx-texclass="INNER">
      <mo data-mjx-texclass="OPEN">(</mo>
      <mi>x</mi>
      <mo data-mjx-texclass="CLOSE">)</mo>
    </mrow>
  </mrow>
</math>

and since the outer <mrow> does not include a TeX class, the spacing is that of INNER when this MathML is read into MathJax (but the spacing is ORD when the TeX input is processed).

This PR causes the serialized MathML to be

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>f</mi>
  <mrow data-mjx-texclass="ORD">
    <mrow data-mjx-texclass="INNER">
      <mo data-mjx-texclass="OPEN">(</mo>
      <mi>x</mi>
      <mo data-mjx-texclass="CLOSE">)</mo>
    </mrow>
  </mrow>
</math>

which gives the same output as the TeX does.

Note that this PR probably will require changes to the test suite, since braced groups will now show data-mix-texclass="ORD" explicitly in situations where it didn't before. (E.g., x^{-4}).

Resolves issue mathjax/MathJax#2585.

@dpvc dpvc requested a review from zorkow December 16, 2020 16:01
@dpvc dpvc added this to the 3.1.3 milestone Jan 31, 2021
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@dpvc
Copy link
Member Author

dpvc commented Feb 9, 2021

I want to do some additional checking before merging this one. There may be an issue with the class changing after the TeXAtom is created.

@dpvc
Copy link
Member Author

dpvc commented Mar 8, 2021

OK, I've checked it out, and I think it is OK. Some of the values may not be strictly necessary, but it does look like they are all getting included in the output now.

@dpvc dpvc merged commit 039a73b into develop Mar 8, 2021
@dpvc dpvc deleted the issue2585 branch March 8, 2021 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants