Error handling for KaTeX plugin

This commit is contained in:
Jermolene
2014-09-24 11:50:49 +02:00
parent 61af1f9379
commit b3df07ae3e
2 changed files with 17 additions and 1 deletions

View File

@@ -36,7 +36,12 @@ KaTeXWidget.prototype.render = function(parent,nextSibling) {
var text = this.getAttribute("text",this.parseTreeNode.text || "");
// Render it into a span
var span = this.document.createElement("span");
katex.render(text,span);
try {
katex.render(text,span);
} catch(ex) {
span.className = "tc-error";
span.textContent = ex;
}
// Insert it into the DOM
parent.insertBefore(span,nextSibling);
this.domNodes.push(span);