fix: MathML \lim\limits in Safari (#2556)

Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
Ron Kok
2020-10-03 05:11:24 -07:00
committed by GitHub
parent 6360401236
commit c8042ccb55
4 changed files with 157 additions and 134 deletions

View File

@@ -164,7 +164,7 @@ const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => {
const operator = new mathMLTree.MathNode("mo", const operator = new mathMLTree.MathNode("mo",
[mml.makeText("\u2061", "text")]); [mml.makeText("\u2061", "text")]);
if (group.parentIsSupSub) { if (group.parentIsSupSub) {
node = new mathMLTree.MathNode("mo", [node, operator]); node = new mathMLTree.MathNode("mrow", [node, operator]);
} else { } else {
node = mathMLTree.newDocumentFragment([node, operator]); node = mathMLTree.newDocumentFragment([node, operator]);
} }

View File

@@ -130,7 +130,7 @@ const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => {
[mml.makeText("\u2061", "text")]); [mml.makeText("\u2061", "text")]);
if (group.parentIsSupSub) { if (group.parentIsSupSub) {
return new mathMLTree.MathNode("mo", [identifier, operator]); return new mathMLTree.MathNode("mrow", [identifier, operator]);
} else { } else {
return mathMLTree.newDocumentFragment([identifier, operator]); return mathMLTree.newDocumentFragment([identifier, operator]);
} }

View File

@@ -260,7 +260,12 @@ defineFunctionBuilders({
} }
} }
const node = new mathMLTree.MathNode(nodeType, children); let node = new mathMLTree.MathNode(nodeType, children);
if (group.base && (group.base.type === "op" ||
group.base.type === "operatorname")) {
node = new mathMLTree.MathNode("mo", [node]);
}
return node; return node;
}, },

View File

@@ -308,15 +308,16 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} correc
<math xmlns="http://www.w3.org/1998/Math/MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics> <semantics>
<mrow> <mrow>
<msub>
<mo> <mo>
<msub>
<mrow>
<mi mathvariant="normal"> <mi mathvariant="normal">
limsup limsup
</mi> </mi>
<mo> <mo>
</mo> </mo>
</mo> </mrow>
<mrow> <mrow>
<mi> <mi>
x x
@@ -329,6 +330,7 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} correc
</mi> </mi>
</mrow> </mrow>
</msub> </msub>
</mo>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty} \\limsup_{x \\rightarrow \\infty}
@@ -343,15 +345,16 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} in dis
> >
<semantics> <semantics>
<mrow> <mrow>
<munder>
<mo> <mo>
<munder>
<mrow>
<mi mathvariant="normal"> <mi mathvariant="normal">
limsup limsup
</mi> </mi>
<mo> <mo>
</mo> </mo>
</mo> </mrow>
<mrow> <mrow>
<mi> <mi>
x x
@@ -364,6 +367,7 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} in dis
</mi> </mi>
</mrow> </mrow>
</munder> </munder>
</mo>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty} \\limsup_{x \\rightarrow \\infty}
@@ -420,6 +424,7 @@ exports[`A MathML builder should render mathchoice as if there was nothing 1`] =
displaystyle="true" displaystyle="true"
> >
<mrow> <mrow>
<mo>
<munderover> <munderover>
<mo> <mo>
@@ -439,6 +444,7 @@ exports[`A MathML builder should render mathchoice as if there was nothing 1`] =
</mi> </mi>
</munderover> </munderover>
</mo>
<msup> <msup>
<mi> <mi>
x x
@@ -461,6 +467,7 @@ exports[`A MathML builder should render mathchoice as if there was nothing 2`] =
<math xmlns="http://www.w3.org/1998/Math/MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics> <semantics>
<mrow> <mrow>
<mo>
<msubsup> <msubsup>
<mo> <mo>
@@ -480,6 +487,7 @@ exports[`A MathML builder should render mathchoice as if there was nothing 2`] =
</mi> </mi>
</msubsup> </msubsup>
</mo>
<msup> <msup>
<mi> <mi>
x x
@@ -695,6 +703,7 @@ exports[`A MathML builder should use <msupsub> for integrals 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="true" displaystyle="true"
> >
<mo>
<msubsup> <msubsup>
<mo> <mo>
@@ -706,9 +715,11 @@ exports[`A MathML builder should use <msupsub> for integrals 1`] = `
b b
</mi> </mi>
</msubsup> </msubsup>
</mo>
<mo> <mo>
+ +
</mo> </mo>
<mo>
<msubsup> <msubsup>
<mo> <mo>
@@ -720,9 +731,11 @@ exports[`A MathML builder should use <msupsub> for integrals 1`] = `
b b
</mi> </mi>
</msubsup> </msubsup>
</mo>
<mo> <mo>
+ +
</mo> </mo>
<mo>
<msubsup> <msubsup>
<mo> <mo>
@@ -734,6 +747,7 @@ exports[`A MathML builder should use <msupsub> for integrals 1`] = `
b b
</mi> </mi>
</msubsup> </msubsup>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
@@ -750,6 +764,7 @@ exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="false" displaystyle="false"
> >
<mo>
<msubsup> <msubsup>
<mo> <mo>
@@ -761,6 +776,7 @@ exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
b b
</mi> </mi>
</msubsup> </msubsup>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
@@ -777,6 +793,7 @@ exports[`A MathML builder should use <munderover> for large operators 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="true" displaystyle="true"
> >
<mo>
<munderover> <munderover>
<mo> <mo>
@@ -788,6 +805,7 @@ exports[`A MathML builder should use <munderover> for large operators 1`] = `
b b
</mi> </mi>
</munderover> </munderover>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">