fix: Catch MathML errors and render the "ERR" block instead.
This commit is contained in:
parent
4c939cefad
commit
82b597ab8b
@ -443,13 +443,25 @@ const math2Svg = (
|
|||||||
: mathJax.amHtml.convert(text, userOptions),
|
: mathJax.amHtml.convert(text, userOptions),
|
||||||
)
|
)
|
||||||
: text;
|
: 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
|
// For rendering
|
||||||
const htmlString = isMathJaxLoaded
|
const htmlString = isMathJaxLoaded
|
||||||
? mathJax.adaptor.outerHTML(mathJax.mmlSvg.convert(mmlString))
|
? mmlError
|
||||||
|
? errorSvg
|
||||||
|
: mathJax.adaptor.outerHTML(mathJax.mmlSvg.convert(mmlString))
|
||||||
: text;
|
: text;
|
||||||
// For accessibility
|
// For accessibility
|
||||||
const ariaString = isMathJaxLoaded
|
const ariaString = isMathJaxLoaded
|
||||||
? useSRE
|
? mmlError
|
||||||
|
? errorAria
|
||||||
|
: useSRE
|
||||||
? mathJax.mmlSre.toSpeech(mmlString)
|
? mathJax.mmlSre.toSpeech(mmlString)
|
||||||
: text
|
: text
|
||||||
: mmlString;
|
: mmlString;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user