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,27 +308,29 @@ 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>
<mi mathvariant="normal"> <mrow>
limsup <mi mathvariant="normal">
</mi> limsup
<mo> </mi>
<mo>
</mo>
</mo> </mo>
<mrow> </mrow>
<mi> <mrow>
x <mi>
</mi> x
<mo> </mi>
<mo>
</mo>
<mi mathvariant="normal"> </mo>
<mi mathvariant="normal">
</mi>
</mrow> </mi>
</msub> </mrow>
</msub>
</mo>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty} \\limsup_{x \\rightarrow \\infty}
@@ -343,27 +345,29 @@ exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} in dis
> >
<semantics> <semantics>
<mrow> <mrow>
<munder> <mo>
<mo> <munder>
<mi mathvariant="normal"> <mrow>
limsup <mi mathvariant="normal">
</mi> limsup
<mo> </mi>
<mo>
</mo>
</mo> </mo>
<mrow> </mrow>
<mi> <mrow>
x <mi>
</mi> x
<mo> </mi>
<mo>
</mo>
<mi mathvariant="normal"> </mo>
<mi mathvariant="normal">
</mi>
</mrow> </mi>
</munder> </mrow>
</munder>
</mo>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty} \\limsup_{x \\rightarrow \\infty}
@@ -420,25 +424,27 @@ exports[`A MathML builder should render mathchoice as if there was nothing 1`] =
displaystyle="true" displaystyle="true"
> >
<mrow> <mrow>
<munderover> <mo>
<mo> <munderover>
</mo>
<mrow>
<mi>
k
</mi>
<mo> <mo>
=
</mo> </mo>
<mn> <mrow>
0 <mi>
</mn> k
</mrow> </mi>
<mi mathvariant="normal"> <mo>
=
</mi> </mo>
</munderover> <mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</munderover>
</mo>
<msup> <msup>
<mi> <mi>
x x
@@ -461,25 +467,27 @@ 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>
<msubsup> <mo>
<mo> <msubsup>
</mo>
<mrow>
<mi>
k
</mi>
<mo> <mo>
=
</mo> </mo>
<mn> <mrow>
0 <mi>
</mn> k
</mrow> </mi>
<mi mathvariant="normal"> <mo>
=
</mi> </mo>
</msubsup> <mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</msubsup>
</mo>
<msup> <msup>
<mi> <mi>
x x
@@ -695,45 +703,51 @@ exports[`A MathML builder should use <msupsub> for integrals 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="true" displaystyle="true"
> >
<msubsup> <mo>
<mo> <msubsup>
<mo>
</mo>
<mi> </mo>
a <mi>
</mi> a
<mi> </mi>
b <mi>
</mi> b
</msubsup> </mi>
</msubsup>
</mo>
<mo> <mo>
+ +
</mo> </mo>
<msubsup> <mo>
<mo> <msubsup>
<mo>
</mo>
<mi> </mo>
a <mi>
</mi> a
<mi> </mi>
b <mi>
</mi> b
</msubsup> </mi>
</msubsup>
</mo>
<mo> <mo>
+ +
</mo> </mo>
<msubsup> <mo>
<mo> <msubsup>
<mo>
</mo>
<mi> </mo>
a <mi>
</mi> a
<mi> </mi>
b <mi>
</mi> b
</msubsup> </mi>
</msubsup>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
@@ -750,17 +764,19 @@ exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="false" displaystyle="false"
> >
<msubsup> <mo>
<mo> <msubsup>
<mo>
</mo>
<mi> </mo>
a <mi>
</mi> a
<mi> </mi>
b <mi>
</mi> b
</msubsup> </mi>
</msubsup>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">
@@ -777,17 +793,19 @@ exports[`A MathML builder should use <munderover> for large operators 1`] = `
<mstyle scriptlevel="0" <mstyle scriptlevel="0"
displaystyle="true" displaystyle="true"
> >
<munderover> <mo>
<mo> <munderover>
<mo>
</mo>
<mi> </mo>
a <mi>
</mi> a
<mi> </mi>
b <mi>
</mi> b
</munderover> </mi>
</munderover>
</mo>
</mstyle> </mstyle>
</mrow> </mrow>
<annotation encoding="application/x-tex"> <annotation encoding="application/x-tex">