Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var SPEAK = function (svg) {
var jax = MathJax.Hub.getJaxFor(svg), id = jax.inputID, mml;
try {mml = jax.root.toMathML('',jax)} catch(err) {
if (!err.restart) {throw err;} // an actual error
if (!queue) {queue = MathJax.Callback.Queue()}
return queue.Push(err.restart,window.Array(SPEAK,svg));
}
jax.speech = speech.processExpression(mml);
svg.setAttribute("role","math");
svg.setAttribute("aria-labelledby",id+"-Title "+id+"-Desc");
for (var i = 0, m = svg.childNodes.length; i < m; i++)
svg.childNodes[i].setAttribute("aria-hidden",true);
var node = MathJax.HTML.Element("desc",{id:id+"-Desc"},[jax.speech]);
svg.insertBefore(node,svg.firstChild);
node = MathJax.HTML.Element("title",{id:id+"-Title"},["Equation"]);
svg.insertBefore(node,svg.firstChild);
}
for (var i = nodes.length-1; i >= 0; i--) SPEAK(nodes[i]);
function AdjustMML() {
if (data.renderer === "NativeMML") {
var nodes = document.getElementsByClassName("MathJax_MathML");
for (var i = nodes.length-1; i >= 0; i--) {
var math = nodes[i].getElementsByTagName("math")[0]
nodes[i].parentNode.replaceChild(math,nodes[i]);
var alttext = speech.processExpression(math.outerHTML.replace(/ /g,"\u00A0"));
if (data.speakText) math.setAttribute("alttext",alttext);
}
}
}