mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Catch MathML errors and render the "ERR" block instead.
This commit is contained in:
parent
4c939cefad
commit
82b597ab8b
1 changed files with 14 additions and 2 deletions
|
@ -443,13 +443,25 @@ const math2Svg = (
|
|||
: mathJax.amHtml.convert(text, userOptions),
|
||||
)
|
||||
: text;
|
||||
let mmlError = false;
|
||||
if (isMathJaxLoaded) {
|
||||
const errDiv = document.createElement("div");
|
||||
errDiv.innerHTML = mmlString;
|
||||
mmlError =
|
||||
errDiv.children[0].children.length > 0 &&
|
||||
errDiv.children[0].children[0].nodeName === "merror";
|
||||
}
|
||||
// For rendering
|
||||
const htmlString = isMathJaxLoaded
|
||||
? mathJax.adaptor.outerHTML(mathJax.mmlSvg.convert(mmlString))
|
||||
? mmlError
|
||||
? errorSvg
|
||||
: mathJax.adaptor.outerHTML(mathJax.mmlSvg.convert(mmlString))
|
||||
: text;
|
||||
// For accessibility
|
||||
const ariaString = isMathJaxLoaded
|
||||
? useSRE
|
||||
? mmlError
|
||||
? errorAria
|
||||
: useSRE
|
||||
? mathJax.mmlSre.toSpeech(mmlString)
|
||||
: text
|
||||
: mmlString;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue