mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 14:08:42 +00:00
Stop throwing ParseError when throwOnError is false (#1169)
* 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
This commit is contained in:
@@ -1,5 +1,39 @@
|
||||
// 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`] = `
|
||||
[
|
||||
{
|
||||
|
Reference in New Issue
Block a user