Skip to content

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Sep 11, 2025

This PR updates the operator dictionary using the one from the MathML4 specification. The MathML spacing values are different from the ones in the MathML3 specification that was used to create our operator table originally, but these only affect the output when MathML spacing is requested. They are also used to define the TeX class in cases where the TeX class isn't explicitly set, and that only changed the values in some obscure instances (like geometric shapes where we used a fairly coarse approach to setting the class in the past). The characters for which there are macros (like \blacktriangle) have their classes set by the TeX input jax, but the change in the operator dictionary may mean they get wrapped in a TeXAtom that overrides the operator dictionary value where it didn't have to before. There are only a few of these.

The MathML4 dictionary no longer include accent or fence attributes, and since we use these, I needed to add those back in, so uses some heuristics to do so.

the main difference is that the | operator is not stretchy when used in infix form, while it used to be stretchy in MathML3. This won't affect the TeX output, as the TeX jax sets stretchy="true" automatically when needed, but it can affect MathML input. That is, something like

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mi>x</mi>
  <mo>+</mo>
  <mo>|</mo>
  <mfrac>
    <mi>a</mi>
    <mi>b</mi>
  </mfrac>
  <mo>|</mo>
  <mo>+</mo>
  <mi>y</mi>
</math>

will no longer have stretchy | around the fraction. This corresponds to the current MathML-Core output, and MathML4's expected output. On the other hand,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mi>x</mi>
  <mo>+</mo>
  <mrow>
    <mo>|</mo>
    <mfrac>
      <mi>a</mi>
      <mi>b</mi>
    </mfrac>
    <mo>|</mo>
  </mrow>
  <mo>+</mo>
  <mi>y</mi>
</math>

will have stretchy | as they are in prefix and postfix form. Since SRE adds the mrow even to the MathML, it should not be much of an issue, even for those using MathML input, unless they disable the semantic enrichment.

Other changes include making many more character stretchy and some symmetric, and reclassifying some BIN and REL operators. It is a little hard to tell these changes, as the MathML spacing value changes meant that the predefined operator definitions in the MO object had to change, and so it appears that there are lots of changes when most are not significant. Ignoring spacing differences helps, but still isn't great. I can provide some better diffs if you want to see them.

These changes required updates to 120 tests (mostly adding or removing stretchy attributes). I couldn't remember how to get your emacs-based diff tools to work, so I ended up writing some scripts to do the updates for me. They need a little more work to be generally applicable, but I'm hoping they will help with these changes in the future.

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.73%. Comparing base (afaf1ea) to head (23b4433).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1352      +/-   ##
===========================================
+ Coverage    86.72%   86.73%   +0.01%     
===========================================
  Files          337      337              
  Lines        84145    84243      +98     
  Branches      3140     3138       -2     
===========================================
+ Hits         72971    73069      +98     
  Misses       11174    11174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant