Skip to content

Commit

Permalink
Merge pull request #315 from mathjax/issue314
Browse files Browse the repository at this point in the history
Fix use of isType() for msubsup and munderover. #314
  • Loading branch information
dpvc authored Aug 21, 2019
2 parents cfa3cac + c7f3da2 commit beb3508
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mathjax3-ts/input/tex/base/BaseItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class PrimeItem extends BaseItem {
*/
public checkItem(item: StackItem): CheckType {
let [top0, top1] = this.Peek(2);
if (!NodeUtil.isType(top0, 'msubsup')) {
if (!NodeUtil.isType(top0, 'msubsup') || NodeUtil.isType(top0, 'msup')) {
// @test Prime, Double Prime
const node = this.create('node', 'msup', [top0, top1]);
return [[node, item], true];
Expand Down
24 changes: 15 additions & 9 deletions mathjax3-ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,19 @@ BaseMethods.Superscript = function(parser: TexParser, c: string) {
const movesupsub = NodeUtil.getProperty(base, 'movesupsub');
let position = NodeUtil.isType(base, 'msubsup') ? (base as MmlMsubsup).sup :
(base as MmlMunderover).over;
if ((NodeUtil.isType(base, 'msubsup') && NodeUtil.getChildAt(base, (base as MmlMsubsup).sup)) ||
(NodeUtil.isType(base, 'munderover') && NodeUtil.getChildAt(base, (base as MmlMunderover).over) &&
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) &&
!NodeUtil.getProperty(base, 'subsupOK'))) {
// @test Double-super-error, Double-over-error
throw new TexError('DoubleExponent', 'Double exponent: use braces to clarify');
}
if (!NodeUtil.isType(base, 'msubsup')) {
if (!NodeUtil.isType(base, 'msubsup') || NodeUtil.isType(base, 'msup')) {
if (movesupsub) {
// @test Move Superscript, Large Operator
if (!NodeUtil.isType(base, 'munderover') || NodeUtil.getChildAt(base, (base as MmlMunderover).over)) {
if (!NodeUtil.isType(base, 'munderover') || NodeUtil.isType(base, 'mover') ||
NodeUtil.getChildAt(base, (base as MmlMunderover).over)) {
if (NodeUtil.getProperty(base, 'movablelimits') && NodeUtil.isType(base, 'mi')) {
// @test Mathop Super
base = ParseUtil.mi2mo(parser, base);
Expand Down Expand Up @@ -184,16 +187,19 @@ BaseMethods.Subscript = function(parser: TexParser, c: string) {
const movesupsub = NodeUtil.getProperty(base, 'movesupsub');
let position = NodeUtil.isType(base, 'msubsup') ?
(base as MmlMsubsup).sub : (base as MmlMunderover).under;
if ((NodeUtil.isType(base, 'msubsup') && NodeUtil.getChildAt(base, (base as MmlMsubsup).sub)) ||
(NodeUtil.isType(base, 'munderover') && NodeUtil.getChildAt(base, (base as MmlMunderover).under) &&
if ((NodeUtil.isType(base, 'msubsup') && !NodeUtil.isType(base, 'msup') &&
NodeUtil.getChildAt(base, (base as MmlMsubsup).sub)) ||
(NodeUtil.isType(base, 'munderover') && !NodeUtil.isType(base, 'mover') &&
NodeUtil.getChildAt(base, (base as MmlMunderover).under) &&
!NodeUtil.getProperty(base, 'subsupOK'))) {
// @test Double-sub-error, Double-under-error
throw new TexError('DoubleSubscripts', 'Double subscripts: use braces to clarify');
}
if (!NodeUtil.isType(base, 'msubsup')) {
if (!NodeUtil.isType(base, 'msubsup') || NodeUtil.isType(base, 'msup')) {
if (movesupsub) {
// @test Large Operator, Move Superscript
if (!NodeUtil.isType(base, 'munderover') || NodeUtil.getChildAt(base, (base as MmlMunderover).under)) {
if (!NodeUtil.isType(base, 'munderover') || NodeUtil.isType(base, 'mover') ||
NodeUtil.getChildAt(base, (base as MmlMunderover).under)) {
if (NodeUtil.getProperty(base, 'movablelimits') && NodeUtil.isType(base, 'mi')) {
// @test Mathop Sub
base = ParseUtil.mi2mo(parser, base);
Expand Down Expand Up @@ -227,7 +233,7 @@ BaseMethods.Prime = function(parser: TexParser, c: string) {
// @test PrimeSup, PrePrime, Prime on Sup
base = parser.create('node', 'mi');
}
if (NodeUtil.isType(base, 'msubsup') &&
if (NodeUtil.isType(base, 'msubsup') && !NodeUtil.isType(base, 'msup') &&
NodeUtil.getChildAt(base, (base as MmlMsubsup).sup)) {
// @test Double Prime Error
throw new TexError('DoubleExponentPrime',
Expand Down

0 comments on commit beb3508

Please sign in to comment.