MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Spacing issue around parenthesis when explorer accessibility is turned on

Open henok-outlier opened this issue 3 years ago • 3 comments

Issue Summary

When the accessibility explorer is activated, there's a spacing issue. The spaces after 'f', 'M', and 'cos' are way too big, and I can't figure out how to make them look right. It's important that those spaces are small for readability reasons, since (for instance) "M(x)" is a single object, not two separate things as "M (x)" might suggest.

Current behavior Screen Shot 2022-05-31 at 12 20 33 AM

Expected behavior Screen Shot 2022-05-31 at 12 21 15 AM

Steps to Reproduce:

  1. Open https://jsbin.com/bohitetaka/edit?html,js,output
  2. Check how math expression is displayed by making accessibility explorer property to false and true.

When explorer is set to false the spacing is correct, but I also want the accessibility feature.

Technical details:

  • MathJax Version: 2.7.7
  • Client OS: Mac OS X 10.14.6
  • Browser: Chrome Version 102.0.5005.61 (Official Build) (x86_64)

Supporting information:

https://jsbin.com/bohitetaka/edit?html,js,output

henok-outlier avatar May 30 '22 21:05 henok-outlier

This is due to the fact that the explorer uses semantic-enrichment that modifies the underlying MathML for the expression, and that adds mrows around the parentheses, which in turn causes MathJax to interpret the parentheses as though they came from \left...\right, which are spaced differently.

This was fixed in v3.1.3 via mathjax/MathJax-src#583, but the fix has not been back-ported to v2.7.

For now, you can use the following configuration to work around the issue:

MathJax.Hub.Register.StartupHook('MathML Jax Ready', function () {
  var PARSE = MathJax.InputJax.MathML.Parse;
  PARSE.Augment({
    _AddChildren: PARSE.prototype.AddChildren,
    AddChildren: function (mml, node) {
      this._AddChildren(mml, node);
      if (mml.type === "mrow" && (mml.open || mml.close)) {
        if (mml.open && !mml.data[0].stretchy) delete mml.open;
        if (mml.close && !mml.data[mml.data.length-1].stretchy) delete mml.close;
      }
    }
  });
});

dpvc avatar Jun 02 '22 11:06 dpvc

MathJax.Hub.Register.StartupHook('MathML Jax Ready', function () {
  var PARSE = MathJax.InputJax.MathML.Parse;
  PARSE.Augment({
    _AddChildren: PARSE.prototype.AddChildren,
    AddChildren: function (mml, node) {
      this._AddChildren(mml, node);
      if (mml.type === "mrow" && (mml.open || mml.close)) {
        if (mml.open && !mml.data[0].stretchy) delete mml.open;
        if (mml.close && !mml.data[mml.data.length-1].stretchy) delete mml.close;
      }
    }
  });
});

@dpvc thanks, I'm thinking the last statement array call is stretchy instead of sretchy. And we don't need the 394 number.

henok-outlier avatar Jun 02 '22 17:06 henok-outlier

Quite correct. Sorry about the typos and copy/paste artifact!

dpvc avatar Jun 02 '22 17:06 dpvc