MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

[4 beta6] underline with prime renders as accent, not superscript

Open pkra opened this issue 1 year ago • 1 comments

In 4.beta-6, \underline{b}' renders the prime as accent

image

instead of superscript (mathjax.org#demo)

image

pkra avatar May 21 '24 09:05 pkra

This one is due to the same commit as #3234, and for the same reason, except in a different place. Here is a configuration that patches the PrimeItem object to replace the incorrect function.

MathJax = {
  startup: {
    ready() {
      const {PrimeItem} = MathJax._.input.tex.base.BaseItems;
      const NodeUtil = MathJax._.input.tex.NodeUtil.default;
      PrimeItem.prototype.checkItem = function(item) {
        let [top0, top1] = this.Peek(2);
        const isSup = NodeUtil.isType(top0, 'msubsup') && !NodeUtil.getChildAt(top0, top0.sup);
        const isOver = NodeUtil.isType(top0, 'munderover') && !NodeUtil.getChildAt(top0, top0.over) &&
                      !NodeUtil.getProperty(top0, 'subsupOK');
        if (!isSup && !isOver) {
          const node = this.create('node', top0.getProperty('movesupsub') ? 'mover' : 'msup', [top0, top1]);
          return [[node, item], true];
        }
        const pos = isSup ? top0.sup : top0.over;
        NodeUtil.setChild(top0, pos, top1);
        return [[top0, item], true];
      }
      MathJax.startup.defaultReady();
    }
  }
};

The subsupOK check was again the missing piece.

Again, I will make a PR for this (combined with the one for #3234).

dpvc avatar May 24 '24 16:05 dpvc