Files
KaTeX/test/__snapshots__/mathml-spec.js.snap
Erik Demaine 485c509879 Cleanup MathML <mrow>, <mtext>, <mn> (#1338)
* Avoid unnecessary <mrow> wrapping

buildMathML gains two helpers:
* `makeRow` helper wraps an array of nodes in `<mrow>`,
  unless the array has length 1, in which case no wrapping is necessary.
* `buildExpressionRow` for common case of `makeRow(buildExpression(...))`

* Combine adjacent <mtext>s in all cases

No more need for `makeTextRow` helper or anything fancy in text MathML handler.

* Concatenate <mn>s and decimal point into single <mn>

Fix #203

* Fix snapshots
2018-05-21 22:56:34 -04:00

560 lines
9.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A MathML builder accents turn into <mover accent="true"> in MathML 1`] = `
<math>
<semantics>
<mrow>
<mover accent="true">
<mi>
u
</mi>
<mo>
¨
</mo>
</mover>
<mi>
b
</mi>
<mi>
e
</mi>
<mi>
r
</mi>
<mi>
f
</mi>
<mi>
i
</mi>
<mi>
a
</mi>
<mi>
n
</mi>
<mi>
c
</mi>
<mover accent="true">
<mi>
e
</mi>
<mo>
ˊ
</mo>
</mover>
<mi>
e
</mi>
</mrow>
<annotation encoding="application/x-tex">
über fiancée
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should concatenate digits into single <mn> 1`] = `
<math>
<semantics>
<mrow>
<mi>
sin
</mi>
<mo>
</mo>
<mi>
α
</mi>
<mo>
=
</mo>
<mn>
0.34
</mn>
</mrow>
<annotation encoding="application/x-tex">
\\sin{\\alpha}=0.34
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should generate <mphantom> nodes for \\phantom 1`] = `
<math>
<semantics>
<mrow>
<mphantom>
<mi>
x
</mi>
</mphantom>
</mrow>
<annotation encoding="application/x-tex">
\\phantom{x}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should generate the right types of nodes 1`] = `
<math>
<semantics>
<mrow>
<mi>
sin
</mi>
<mo>
</mo>
<mi>
x
</mi>
<mo>
+
</mo>
<mn>
1
</mn>
<mspace width="0.277778em">
</mspace>
<mtext>
a
</mtext>
</mrow>
<annotation encoding="application/x-tex">
\\sin{x}+1\\;\\text{a}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should make prime operators into <mo> nodes 1`] = `
<math>
<semantics>
<mrow>
<msup>
<mi>
f
</mi>
<mo mathvariant="normal">
</mo>
</msup>
</mrow>
<annotation encoding="application/x-tex">
f&#x27;
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} correctly in \\textstyle 1`] = `
<math>
<semantics>
<mrow>
<msub>
<mo>
<mi mathvariant="normal">
limsup
</mi>
<mo>
</mo>
</mo>
<mrow>
<mi>
x
</mi>
<mo>
</mo>
<mi mathvariant="normal">
</mi>
</mrow>
</msub>
</mrow>
<annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should output \\limsup_{x \\rightarrow \\infty} in displaymode correctly 1`] = `
<math>
<semantics>
<mrow>
<munder>
<mo>
<mi mathvariant="normal">
limsup
</mi>
<mo>
</mo>
</mo>
<mrow>
<mi>
x
</mi>
<mo>
</mo>
<mi mathvariant="normal">
</mi>
</mrow>
</munder>
</mrow>
<annotation encoding="application/x-tex">
\\limsup_{x \\rightarrow \\infty}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render boldsymbol with the correct mathvariants 1`] = `
<math>
<semantics>
<mrow>
<mi mathvariant="bold-italic">
A
</mi>
<mi mathvariant="bold-italic">
x
</mi>
<mn mathvariant="bold-italic">
2
</mn>
<mi mathvariant="bold-italic">
k
</mi>
<mi mathvariant="bold-italic">
ω
</mi>
<mi mathvariant="bold-italic">
Ω
</mi>
<mi mathvariant="bold-italic">
ı
</mi>
<mo mathvariant="bold-italic">
+
</mo>
</mrow>
<annotation encoding="application/x-tex">
\\boldsymbol{Ax2k\\omega\\Omega\\imath+}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 1`] = `
<math>
<semantics>
<mrow>
<mstyle scriptlevel="0"
displaystyle="true"
>
<mrow>
<munderover>
<mo>
</mo>
<mrow>
<mi>
k
</mi>
<mo>
=
</mo>
<mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</munderover>
<msup>
<mi>
x
</mi>
<mi>
k
</mi>
</msup>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">
\\displaystyle\\mathchoice{\\sum_{k = 0}^{\\infty} x^k}{T}{S}{SS}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 2`] = `
<math>
<semantics>
<mrow>
<msubsup>
<mo>
</mo>
<mrow>
<mi>
k
</mi>
<mo>
=
</mo>
<mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</msubsup>
<msup>
<mi>
x
</mi>
<mi>
k
</mi>
</msup>
</mrow>
<annotation encoding="application/x-tex">
\\mathchoice{D}{\\sum_{k = 0}^{\\infty} x^k}{S}{SS}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 3`] = `
<math>
<semantics>
<mrow>
<msub>
<mi>
x
</mi>
<mi>
T
</mi>
</msub>
</mrow>
<annotation encoding="application/x-tex">
x_{\\mathchoice{D}{T}{\\sum_{k = 0}^{\\infty} x^k}{SS}}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 4`] = `
<math>
<semantics>
<mrow>
<msub>
<mi>
x
</mi>
<msub>
<mi>
y
</mi>
<mi>
T
</mi>
</msub>
</msub>
</mrow>
<annotation encoding="application/x-tex">
x_{y_{\\mathchoice{D}{T}{S}{\\sum_{k = 0}^{\\infty} x^k}}}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should set href attribute for href appropriately 1`] = `
<math>
<semantics>
<mrow>
<mi href="http://example.org">
α
</mi>
</mrow>
<annotation encoding="application/x-tex">
\\href{http://example.org}{\\alpha}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <menclose> for colorbox 1`] = `
<math>
<semantics>
<mrow>
<menclose mathbackground="red">
<mtext>
b
</mtext>
</menclose>
</mrow>
<annotation encoding="application/x-tex">
\\colorbox{red}{b}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <mpadded> for raisebox 1`] = `
<math>
<semantics>
<mrow>
<mpadded voffset="0.25em">
<mtext>
b
</mtext>
</mpadded>
</mrow>
<annotation encoding="application/x-tex">
\\raisebox{0.25em}{b}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <msupsub> for regular operators 1`] = `
<math>
<semantics>
<mrow>
<mstyle scriptlevel="0"
displaystyle="false"
>
<msubsup>
<mo>
</mo>
<mi>
a
</mi>
<mi>
b
</mi>
</msubsup>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">
\\textstyle\\sum_a^b
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <munderover> for large operators 1`] = `
<math>
<semantics>
<mrow>
<mstyle scriptlevel="0"
displaystyle="true"
>
<munderover>
<mo>
</mo>
<mi>
a
</mi>
<mi>
b
</mi>
</munderover>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">
\\displaystyle\\sum_a^b
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder tags use <mlabeledtr> 1`] = `
<math>
<semantics>
<mtable side="right">
<mlabeledtr>
<mtd>
<mtext>
(hi)
</mtext>
</mtd>
<mtd>
<mrow>
<mi>
x
</mi>
<mo>
+
</mo>
<msup>
<mi>
y
</mi>
<mn>
2
</mn>
</msup>
</mrow>
</mtd>
</mlabeledtr>
</mtable>
<annotation encoding="application/x-tex">
\\tag{hi} x+y^2
</annotation>
</semantics>
</math>
`;