Files
KaTeX/test/__snapshots__/katex-spec.js.snap
Ron Kok 9822414733 Render MathML directly (#1966)
* Render MathML

* Fix lint error

* Change from main api to rendering options
2019-05-13 19:31:04 -04:00

1065 lines
20 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

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 begin/end parser should grab \\arraystretch 1`] = `
[
{
"type": "array",
"arraystretch": 1.5,
"body": [
[
{
"type": "styling",
"body": [
{
"type": "ordgroup",
"body": [
{
"type": "mathord",
"loc": {
"end": 37,
"lexer": {
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
"lastIndex": 56
},
"start": 36
},
"mode": "math",
"text": "a"
}
],
"mode": "math"
}
],
"mode": "math",
"style": "text"
},
{
"type": "styling",
"body": [
{
"type": "ordgroup",
"body": [
{
"type": "mathord",
"loc": {
"end": 39,
"lexer": {
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
"lastIndex": 56
},
"start": 38
},
"mode": "math",
"text": "b"
}
],
"mode": "math"
}
],
"mode": "math",
"style": "text"
}
],
[
{
"type": "styling",
"body": [
{
"type": "ordgroup",
"body": [
{
"type": "mathord",
"loc": {
"end": 42,
"lexer": {
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
"lastIndex": 56
},
"start": 41
},
"mode": "math",
"text": "c"
}
],
"mode": "math"
}
],
"mode": "math",
"style": "text"
},
{
"type": "styling",
"body": [
{
"type": "ordgroup",
"body": [
{
"type": "mathord",
"loc": {
"end": 44,
"lexer": {
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
"lastIndex": 56
},
"start": 43
},
"mode": "math",
"text": "d"
}
],
"mode": "math"
}
],
"mode": "math",
"style": "text"
}
]
],
"hLinesBeforeRow": [
[
],
[
],
[
]
],
"hskipBeforeAndAfter": false,
"mode": "math",
"rowGaps": [
null
]
}
]
`;
exports[`A font parser \\boldsymbol should inherit mbin/mrel from argument 1`] = `
[
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.43056,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "a",
"width": 0.52859
},
{
"attributes": {
},
"children": [
{
"attributes": {
},
"children": [
],
"classes": [
"mord"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
}
}
],
"classes": [
"mord"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.69444,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "b",
"width": 0.42917
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2777777777777778em"
}
},
{
"attributes": {
},
"children": [
{
"attributes": {
},
"children": [
{
"classes": [
"mrel",
"mathbf"
],
"depth": -0.10889,
"height": 0.39111,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "=",
"width": 0.89444
}
],
"classes": [
"mord"
],
"depth": 0,
"height": 0.39111,
"maxFontSize": 1,
"style": {
}
}
],
"classes": [
"mrel"
],
"depth": 0,
"height": 0.39111,
"maxFontSize": 1,
"style": {
}
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2777777777777778em"
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.43056,
"italic": 0,
"maxFontSize": 1,
"skew": 0.05556,
"style": {
},
"text": "c",
"width": 0.43276
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"attributes": {
},
"children": [
{
"attributes": {
},
"children": [
{
"classes": [
"mord",
"mathbf"
],
"depth": 0.13333,
"height": 0.63333,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "+",
"width": 0.89444
}
],
"classes": [
"mord"
],
"depth": 0.13333,
"height": 0.63333,
"maxFontSize": 1,
"style": {
}
}
],
"classes": [
"mbin"
],
"depth": 0.13333,
"height": 0.63333,
"maxFontSize": 1,
"style": {
}
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.69444,
"italic": 0,
"maxFontSize": 1,
"skew": 0.16667,
"style": {
},
"text": "d",
"width": 0.52049
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"attributes": {
},
"children": [
{
"attributes": {
},
"children": [
{
"classes": [
"mord",
"mathbf"
],
"depth": 0.13333,
"height": 0.63333,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "+",
"width": 0.89444
},
{
"classes": [
"mord",
"mathbf"
],
"depth": 0.13333,
"height": 0.63333,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "+",
"width": 0.89444
}
],
"classes": [
"mord"
],
"depth": 0.13333,
"height": 0.63333,
"maxFontSize": 1,
"style": {
}
}
],
"classes": [
"mbin"
],
"depth": 0.13333,
"height": 0.63333,
"maxFontSize": 1,
"style": {
}
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.43056,
"italic": 0,
"maxFontSize": 1,
"skew": 0.05556,
"style": {
},
"text": "e",
"width": 0.46563
},
{
"attributes": {
},
"children": [
{
"attributes": {
},
"children": [
{
"classes": [
"mord",
"boldsymbol"
],
"depth": 0,
"height": 0.44444,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "x",
"width": 0.65903
},
{
"classes": [
"mord",
"boldsymbol"
],
"depth": 0.19444,
"height": 0.44444,
"italic": 0.03704,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "y",
"width": 0.59028
},
{
"classes": [
"mord",
"boldsymbol"
],
"depth": 0,
"height": 0.44444,
"italic": 0.04213,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "z",
"width": 0.55509
}
],
"classes": [
"mord"
],
"depth": 0.19444,
"height": 0.44444,
"maxFontSize": 1,
"style": {
}
}
],
"classes": [
"mord"
],
"depth": 0.19444,
"height": 0.44444,
"maxFontSize": 1,
"style": {
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0.19444,
"height": 0.69444,
"italic": 0.10764,
"maxFontSize": 1,
"skew": 0.16667,
"style": {
},
"text": "f",
"width": 0.48959
}
]
`;
exports[`A parse tree generator generates a tree 1`] = `
[
{
"type": "supsub",
"base": {
"type": "mathord",
"mode": "math",
"text": "\\\\sigma"
},
"mode": "math",
"sup": {
"type": "textord",
"mode": "math",
"text": "2"
}
}
]
`;
exports[`A parser that does not throw on unsupported commands should build katex-error span for other type of KaTeX error 1`] = `
{
"attributes": {
"style": "color:#933",
"title": "ParseError: KaTeX parse error: Double superscript at position 4: 2^2^̲2"
},
"children": [
{
"classes": [
],
"depth": 0,
"height": 0,
"italic": 0,
"maxFontSize": 0,
"skew": 0,
"style": {
},
"text": "2^2^2",
"width": 0
}
],
"classes": [
"katex-error"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
}
}
`;
exports[`A parser that does not throw on unsupported commands should properly escape LaTeX in errors 1`] = `
<span class="katex-error"
title="ParseError: KaTeX parse error: Expected group after &#x27;^&#x27; at position 2: 2^̲&amp;&quot;&lt;&gt;"
style="color:#933"
>
2^&amp;&quot;&lt;&gt;
</span>
`;
exports[`An implicit group parser within optional groups should work style commands \\sqrt[\\textstyle 3]{x} 1`] = `
[
{
"type": "sqrt",
"body": {
"type": "ordgroup",
"body": [
{
"type": "mathord",
"mode": "math",
"text": "x"
}
],
"mode": "math"
},
"index": {
"type": "ordgroup",
"body": [
{
"type": "styling",
"body": [
{
"type": "textord",
"mode": "math",
"text": "3"
}
],
"mode": "math",
"style": "text"
}
],
"mode": "math"
},
"mode": "math"
}
]
`;
exports[`An implicit group parser within optional groups should work with \\color: \\sqrt[\\color{red} 3]{x} 1`] = `
[
{
"type": "sqrt",
"body": {
"type": "ordgroup",
"body": [
{
"type": "mathord",
"mode": "math",
"text": "x"
}
],
"mode": "math"
},
"index": {
"type": "ordgroup",
"body": [
{
"type": "color",
"body": [
{
"type": "textord",
"mode": "math",
"text": "3"
}
],
"color": "red",
"mode": "math"
}
],
"mode": "math"
},
"mode": "math"
}
]
`;
exports[`An implicit group parser within optional groups should work with old font functions: \\sqrt[\\tt 3]{x} 1`] = `
[
{
"type": "sqrt",
"body": {
"type": "ordgroup",
"body": [
{
"type": "mathord",
"mode": "math",
"text": "x"
}
],
"mode": "math"
},
"index": {
"type": "ordgroup",
"body": [
{
"type": "font",
"body": {
"type": "ordgroup",
"body": [
{
"type": "textord",
"mode": "math",
"text": "3"
}
],
"mode": "math"
},
"font": "mathtt",
"mode": "math"
}
],
"mode": "math"
},
"mode": "math"
}
]
`;
exports[`An implicit group parser within optional groups should work with sizing commands: \\sqrt[\\small 3]{x} 1`] = `
[
{
"type": "sqrt",
"body": {
"type": "ordgroup",
"body": [
{
"type": "mathord",
"mode": "math",
"text": "x"
}
],
"mode": "math"
},
"index": {
"type": "ordgroup",
"body": [
{
"type": "sizing",
"body": [
{
"type": "textord",
"mode": "math",
"text": "3"
}
],
"mode": "math",
"size": 5
}
],
"mode": "math"
},
"mode": "math"
}
]
`;
exports[`Extending katex by new fonts and symbols Add new font class to new extended symbols 1`] = `
<span class="katex">
<span class="katex-mathml">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mrow>
<mi mathvariant="normal">
۹
</mi>
<msup>
<mi mathvariant="normal">
۹
</mi>
<mrow>
<mi mathvariant="normal">
۱
</mi>
<mi mathvariant="normal">
۱
</mi>
</mrow>
</msup>
</mrow>
<annotation encoding="application/x-tex">
۹۹^{۱۱}
</annotation>
</semantics>
</math>
</span>
<span class="katex-html"
aria-hidden="true"
>
<span class="base">
<span class="strut"
style="height:0.84425em;vertical-align:0em;"
>
</span>
<span class="mord mockEasternArabicFont-Regular">
۹
</span>
<span class="mord">
<span class="mord mockEasternArabicFont-Regular">
۹
</span>
<span class="msupsub">
<span class="vlist-t">
<span class="vlist-r">
<span class="vlist"
style="height:0.84425em;"
>
<span style="top:-3.063em;margin-right:0.05em;">
<span class="pstrut"
style="height:2.7em;"
>
</span>
<span class="sizing reset-size6 size3 mtight">
<span class="mord mtight">
<span class="mord mockEasternArabicFont-Regular mtight">
۱
</span>
<span class="mord mockEasternArabicFont-Regular mtight">
۱
</span>
</span>
</span>
</span>
</span>
</span>
</span>
</span>
</span>
</span>
</span>
</span>
`;
exports[`Newlines via \\\\ and \\newline \\\\ causes newline, even after mrel and mop 1`] = `
<span class="katex">
<span class="katex-mathml">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mrow>
<mi>
M
</mi>
<mo>
=
</mo>
<mspace linebreak="newline">
</mspace>
<mi>
a
</mi>
<mo>
+
</mo>
<mspace linebreak="newline">
</mspace>
<mi>
b
</mi>
<mspace linebreak="newline">
</mspace>
<mi>
c
</mi>
</mrow>
<annotation encoding="application/x-tex">
M = \\\\ a + \\\\ b \\\\ c
</annotation>
</semantics>
</math>
</span>
<span class="katex-html"
aria-hidden="true"
>
<span class="base">
<span class="strut"
style="height:0.68333em;vertical-align:0em;"
>
</span>
<span class="mord mathdefault"
style="margin-right:0.10903em;"
>
M
</span>
<span class="mspace"
style="margin-right:0.2777777777777778em;"
>
</span>
<span class="mrel">
=
</span>
<span class="mspace"
style="margin-right:0.2777777777777778em;"
>
</span>
</span>
<span class="mspace newline">
</span>
<span class="base">
<span class="strut"
style="height:0.66666em;vertical-align:-0.08333em;"
>
</span>
<span class="mord mathdefault">
a
</span>
<span class="mspace"
style="margin-right:0.2222222222222222em;"
>
</span>
<span class="mbin">
+
</span>
<span class="mspace"
style="margin-right:0.2222222222222222em;"
>
</span>
</span>
<span class="mspace newline">
</span>
<span class="base">
<span class="strut"
style="height:0.69444em;vertical-align:0em;"
>
</span>
<span class="mord mathdefault">
b
</span>
</span>
<span class="mspace newline">
</span>
<span class="base">
<span class="strut"
style="height:0.43056em;vertical-align:0em;"
>
</span>
<span class="mord mathdefault">
c
</span>
</span>
</span>
</span>
`;
exports[`href and url commands should not affect spacing around 1`] = `
[
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.43056,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "a",
"width": 0.52859
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"attributes": {
"href": "http://example.com/"
},
"children": [
{
"classes": [
"mbin"
],
"depth": 0.08333,
"height": 0.58333,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "+",
"width": 0.77778
},
{
"attributes": {
},
"children": [
],
"classes": [
"mspace"
],
"depth": 0,
"height": 0,
"maxFontSize": 0,
"style": {
"marginRight": "0.2222222222222222em"
}
},
{
"classes": [
"mord",
"mathdefault"
],
"depth": 0,
"height": 0.69444,
"italic": 0,
"maxFontSize": 1,
"skew": 0,
"style": {
},
"text": "b",
"width": 0.42917
}
],
"classes": [
],
"depth": 0.08333,
"height": 0.69444,
"maxFontSize": 1,
"style": {
}
}
]
`;