Skip to content

Commit

Permalink
Merge pull request #1069 from mathjax/issue3202
Browse files Browse the repository at this point in the history
Handle primes in munderover as in msubsup.  (mathjax/MathJax#3202)
  • Loading branch information
dpvc committed Mar 16, 2024
2 parents 5b28ff8 + 70ea011 commit c837e91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
12 changes: 6 additions & 6 deletions ts/core/MmlTree/OperatorDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ export const OPTABLE: {[form: string]: OperatorList} = {
'\u201E': MO.ACCENT, // double low-9 quotation mark
'\u201F': MO.ACCENT, // double high-reversed-9 quotation mark
'\u2032': MO.ORD, // prime
'\u2033': MO.ACCENT, // double prime
'\u2034': MO.ACCENT, // triple prime
'\u2035': MO.ACCENT, // reversed prime
'\u2036': MO.ACCENT, // reversed double prime
'\u2037': MO.ACCENT, // reversed triple prime
'\u2033': MO.ORD, // double prime
'\u2034': MO.ORD, // triple prime
'\u2035': MO.ORD, // reversed prime
'\u2036': MO.ORD, // reversed double prime
'\u2037': MO.ORD, // reversed triple prime
'\u203E': MO.WIDEACCENT, // overline
'\u2057': MO.ACCENT, // quadruple prime
'\u2057': MO.ORD, // quadruple prime
'\u20DB': MO.ACCENT, // combining three dots above
'\u20DC': MO.ACCENT, // combining four dots above
'\u2309': MO.CLOSE, // right ceiling
Expand Down
10 changes: 7 additions & 3 deletions ts/input/tex/base/BaseItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {entities} from '../../../util/Entities.js';
import {MmlNode, TextNode, TEXCLASS} from '../../../core/MmlTree/MmlNode.js';
import {MmlMo} from '../../../core/MmlTree/MmlNodes/mo.js';
import {MmlMsubsup} from '../../../core/MmlTree/MmlNodes/msubsup.js';
import {MmlMunderover} from '../../../core/MmlTree/MmlNodes/munderover.js';
import TexParser from '../TexParser.js';
import TexError from '../TexError.js';
import {ParseUtil} from '../ParseUtil.js';
Expand Down Expand Up @@ -206,12 +207,15 @@ export class PrimeItem extends BaseItem {
*/
public checkItem(item: StackItem): CheckType {
let [top0, top1] = this.Peek(2);
if (!NodeUtil.isType(top0, 'msubsup') || NodeUtil.isType(top0, 'msup')) {
const isSup = NodeUtil.isType(top0, 'msubsup') && !NodeUtil.getChildAt(top0, (top0 as MmlMsubsup).sup);
const isOver = NodeUtil.isType(top0, 'munderover') && !NodeUtil.getChildAt(top0, (top0 as MmlMunderover).over);
if (!isSup && !isOver) {
// @test Prime, Double Prime
const node = this.create('node', 'msup', [top0, top1]);
const node = this.create('node', top0.getProperty('movesupsub') ? 'mover' : 'msup', [top0, top1]);
return [[node, item], true];
}
NodeUtil.setChild(top0, (top0 as MmlMsubsup).sup, top1);
const pos = isSup ? (top0 as MmlMsubsup).sup : (top0 as MmlMunderover).over;
NodeUtil.setChild(top0, pos, top1);
return [[top0, item], true];
}
}
Expand Down
6 changes: 4 additions & 2 deletions ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ BaseMethods.Prime = function(parser: TexParser, c: string) {
// @test PrimeSup, PrePrime, Prime on Sup
base = parser.create('token', 'mi');
}
if (NodeUtil.isType(base, 'msubsup') && !NodeUtil.isType(base, 'msup') &&
NodeUtil.getChildAt(base, (base as MmlMsubsup).sup)) {
if ((NodeUtil.isType(base, 'msubsup') && !NodeUtil.isType(base, 'msup') &&
NodeUtil.getChildAt(base, (base as MmlMsubsup).sup)) ||
(NodeUtil.isType(base, 'munderover') && !NodeUtil.isType(base, 'mover') &&
NodeUtil.getChildAt(base, (base as MmlMunderover).over))) {
// @test Double Prime Error
throw new TexError('DoubleExponentPrime',
'Prime causes double exponent: use braces to clarify');
Expand Down

0 comments on commit c837e91

Please sign in to comment.