mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
* Stop throwing ParseError when throwOnError is false `render`, `renderToString`, etc. now catch ParseError and render it to the raw LaTeX (with proper escaping) and a hover title with the error. Along the way: * Use new `katex.__renderToDomTree` in katex-spec's `_getBuilt`. (This was necessary to get the new error handling in `_getBuilt`.) * Fix jest results which must always be functions, not strings. * fix lint * Fix flow error Leave error type unspecified, as we check it with instanceof. * Update katex-spec.js
216 lines
4.6 KiB
Plaintext
216 lines
4.6 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
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": {
|
|
},
|
|
"value": "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 '^' at position 2: 2^̲&"<>\\" style=\\"color:#933\\">2^&"<></span>"`;
|
|
|
|
exports[`An implicit group parser within optional groups should work style commands \\sqrt[\\textstyle 3]{x} 1`] = `
|
|
[
|
|
{
|
|
"type": "sqrt",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "sqrt",
|
|
"body": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "mathord",
|
|
"mode": "math",
|
|
"value": "x"
|
|
}
|
|
]
|
|
},
|
|
"index": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "styling",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "styling",
|
|
"style": "text",
|
|
"value": [
|
|
{
|
|
"type": "textord",
|
|
"mode": "math",
|
|
"value": "3"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
`;
|
|
|
|
exports[`An implicit group parser within optional groups should work with \\color: \\sqrt[\\color{red} 3]{x} 1`] = `
|
|
[
|
|
{
|
|
"type": "sqrt",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "sqrt",
|
|
"body": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "mathord",
|
|
"mode": "math",
|
|
"value": "x"
|
|
}
|
|
]
|
|
},
|
|
"index": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "color",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "color",
|
|
"color": "red",
|
|
"value": [
|
|
{
|
|
"type": "textord",
|
|
"mode": "math",
|
|
"value": "3"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
`;
|
|
|
|
exports[`An implicit group parser within optional groups should work with old font functions: \\sqrt[\\tt 3]{x} 1`] = `
|
|
[
|
|
{
|
|
"type": "sqrt",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "sqrt",
|
|
"body": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "mathord",
|
|
"mode": "math",
|
|
"value": "x"
|
|
}
|
|
]
|
|
},
|
|
"index": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "font",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "font",
|
|
"body": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "textord",
|
|
"mode": "math",
|
|
"value": "3"
|
|
}
|
|
]
|
|
},
|
|
"font": "mathtt"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
`;
|
|
|
|
exports[`An implicit group parser within optional groups should work with sizing commands: \\sqrt[\\small 3]{x} 1`] = `
|
|
[
|
|
{
|
|
"type": "sqrt",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "sqrt",
|
|
"body": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "mathord",
|
|
"mode": "math",
|
|
"value": "x"
|
|
}
|
|
]
|
|
},
|
|
"index": {
|
|
"type": "ordgroup",
|
|
"mode": "math",
|
|
"value": [
|
|
{
|
|
"type": "sizing",
|
|
"mode": "math",
|
|
"value": {
|
|
"type": "sizing",
|
|
"size": 5,
|
|
"value": [
|
|
{
|
|
"type": "textord",
|
|
"mode": "math",
|
|
"value": "3"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
`;
|