diff --git a/src/functions/mclass.js b/src/functions/mclass.js index f2d86103..6f63c483 100644 --- a/src/functions/mclass.js +++ b/src/functions/mclass.js @@ -99,6 +99,7 @@ defineFunction({ mode: baseArg.mode, limits: true, alwaysHandleSupSub: true, + parentIsSupSub: false, symbol: false, suppressBaseShift: funcName !== "\\stackrel", body: ordargument(baseArg), diff --git a/src/functions/op.js b/src/functions/op.js index 6600b35e..69fd9b60 100644 --- a/src/functions/op.js +++ b/src/functions/op.js @@ -252,15 +252,19 @@ const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => { // operator's name. // TODO(emily): Add a space in the middle of some of these // operators, like \limsup. - node = new mathMLTree.MathNode( - "mi", [new mathMLTree.TextNode(group.name.slice(1))]); + if (group.parentIsSupSub) { + node = new mathMLTree.MathNode( + "mo", [new mathMLTree.TextNode(group.name.slice(1))]); + } else { + node = new mathMLTree.MathNode( + "mi", [new mathMLTree.TextNode(group.name.slice(1))]); + // Append an . + // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 + const operator = new mathMLTree.MathNode("mo", + [mml.makeText("\u2061", "text")]); - // Append an . - // ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4 - const operator = new mathMLTree.MathNode("mo", - [mml.makeText("\u2061", "text")]); - - return mathMLTree.newDocumentFragment([node, operator]); + return mathMLTree.newDocumentFragment([node, operator]); + } } return node; @@ -302,6 +306,7 @@ defineFunction({ type: "op", mode: parser.mode, limits: true, + parentIsSupSub: false, symbol: true, name: fName, }; @@ -324,6 +329,7 @@ defineFunction({ type: "op", mode: parser.mode, limits: false, + parentIsSupSub: false, symbol: false, body: ordargument(body), }; @@ -363,6 +369,7 @@ defineFunction({ type: "op", mode: parser.mode, limits: false, + parentIsSupSub: false, symbol: false, name: funcName, }; @@ -385,6 +392,7 @@ defineFunction({ type: "op", mode: parser.mode, limits: true, + parentIsSupSub: false, symbol: false, name: funcName, }; @@ -412,6 +420,7 @@ defineFunction({ type: "op", mode: parser.mode, limits: false, + parentIsSupSub: false, symbol: true, name: fName, }; diff --git a/src/functions/supsub.js b/src/functions/supsub.js index c1ed88c6..583294c0 100644 --- a/src/functions/supsub.js +++ b/src/functions/supsub.js @@ -201,6 +201,10 @@ defineFunctionBuilders({ } } + if (group.base && group.base.type === "op") { + group.base.parentIsSupSub = true; + } + const children = [mml.buildGroup(group.base, options)]; if (group.sub) { diff --git a/src/parseNode.js b/src/parseNode.js index 87b9c919..a8f790b3 100644 --- a/src/parseNode.js +++ b/src/parseNode.js @@ -66,6 +66,7 @@ type ParseNodeTypes = { limits: boolean, alwaysHandleSupSub?: boolean, suppressBaseShift?: boolean, + parentIsSupSub: boolean, symbol: boolean, name: string, body?: void, @@ -76,6 +77,7 @@ type ParseNodeTypes = { limits: boolean, alwaysHandleSupSub?: boolean, suppressBaseShift?: boolean, + parentIsSupSub: boolean, symbol: false, // If 'symbol' is true, `body` *must* be set. name?: void, body: AnyParseNode[],