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

[v4 beta 6] overline + prime causing unexpected "double exponent" error #3234

Open
pkra opened this issue May 21, 2024 · 1 comment
Open
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch Test Needed v4

Comments

@pkra
Copy link
Contributor

pkra commented May 21, 2024

Our testing ran into a lot of unexpected Prime causes double exponent: use braces to clarify processing errors after upgrading.

It seems to always come down to overline and primes, e.g.,

  • \overline{\mathfrak{D}}'_j
  • \overline{c}''=\overline{n}
  • \begin{equation*} \|\overline{c}'\|_{\infty }\leqslant \|\overline{n}\|_{1}= \|n\|_{1}. \end{equation*}
@dpvc dpvc added Accepted Issue has been reproduced by MathJax team v4 labels May 24, 2024
@dpvc
Copy link
Member

dpvc commented May 24, 2024

This is due to the changes from mathjax/MathJax-src/pull/1069, which left out a check after

https://github.com/mathjax/MathJax-src/blob/70ea011e8f84eeefb352e5167e843a6033c42d3a/ts/input/tex/base/BaseMethods.ts#L260

like

https://github.com/mathjax/MathJax-src/blob/70ea011e8f84eeefb352e5167e843a6033c42d3a/ts/input/tex/base/BaseMethods.ts#L161

Here is a configuration that can be used to add that in:

MathJax = {
  tex: {packages: {'[+]': ['fix-primes']}},
  startup: {
    ready() {
      const {MacroMap} = MathJax._.input.tex.TokenMap;
      const {Configuration} = MathJax._.input.tex.Configuration;
      const NodeUtil = MathJax._.input.tex.NodeUtil.default;
      const {entities} = MathJax._.util.Entities;
      new MacroMap('fix-primes', {
        '\'':  'Prime',
        '\u2019': 'Prime',
        '\u2032': 'Prime'
      }, {
        Prime(parser, c) {
          let base = parser.stack.Prev();
          if (!base) {
            base = parser.create('token', 'mi');
          }
          if ((NodeUtil.isType(base, 'msubsup') && !NodeUtil.isType(base, 'msup') &&
               NodeUtil.getChildAt(base, base.sup)) ||
              (NodeUtil.isType(base, 'munderover') && !NodeUtil.isType(base, 'mover') &&
               NodeUtil.getChildAt(base, base.over) &&
               !NodeUtil.getProperty(base, 'subsupOK'))) {
            throw new TexError('DoubleExponentPrime', 'Prime causes double exponent: use braces to clarify');
          }
          let sup = '';
          parser.i--;
          do {
            sup += entities.prime; parser.i++, c = parser.GetNext();
          } while (c === '\'' || c === entities.rsquo || c === entities.prime);
          sup = ['', '\u2032', '\u2033', '\u2034', '\u2057'][sup.length] || sup;
          const node = parser.create('token', 'mo', {variantForm: true}, sup);
          parser.Push(parser.itemFactory.create('prime', base, node));
        }
      });
      Configuration.create('fix-primes', {
        handler: {character: ['fix-primes']}
      });
      MathJax.startup.defaultReady();
    }
  }
};

I will make a PR to add the missing check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Merged Merged into develop branch Test Needed v4
Projects
None yet
Development

No branches or pull requests

2 participants