diff --git a/src/functions/mclass.js b/src/functions/mclass.js index f285f3fb..e598ba58 100644 --- a/src/functions/mclass.js +++ b/src/functions/mclass.js @@ -22,7 +22,7 @@ function mathmlBuilder(group: ParseNode<"mclass">, options) { const inner = mml.buildExpression(group.body, options); if (group.mclass === "minner") { - return mathMLTree.newDocumentFragment(inner); + node = new mathMLTree.MathNode("mpadded", inner); } else if (group.mclass === "mord") { if (group.isCharacterBox) { node = inner[0]; @@ -49,6 +49,9 @@ function mathmlBuilder(group: ParseNode<"mclass">, options) { } else if (group.mclass === "mopen" || group.mclass === "mclose") { node.attributes.lspace = "0em"; node.attributes.rspace = "0em"; + } else if (group.mclass === "minner") { + node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option + node.attributes.width = "+0.1111em"; } // MathML default space is 5/18 em, so needs no action. // Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo diff --git a/test/katex-spec.js b/test/katex-spec.js index c45783ab..15cd8a29 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -101,6 +101,19 @@ describe("A rel parser", function() { }); }); +describe("A mathinner parser", function() { + it("should not fail", function() { + expect("\\mathinner{\\langle{\\psi}\\rangle}").toParse(); + expect("\\frac 1 {\\mathinner{\\langle{\\psi}\\rangle}}").toParse(); + }); + + it("should return one group, not a fragment", function() { + const contents = "\\mathinner{\\langle{\\psi}\\rangle}"; + const mml = buildMathML(getParsed(contents), contents, defaultOptions); + expect(mml.children.length).toEqual(1); + }); +}); + describe("A punct parser", function() { const expression = ",;";