Update KaTeX wrapper to support operation under Node.js

Now we can generate static HTML containing mathematical typesetting
This commit is contained in:
Jermolene
2014-10-06 21:20:19 +01:00
parent cbe2a53d6a
commit 63c174d7ed
5 changed files with 18 additions and 7 deletions
@@ -78,7 +78,9 @@
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/katex/katex.min.js",
"module-type": "library"
}
},
"prefix": "(function(document) {\n",
"suffix": "\n})($tw.node ? $tw.fakeDocument : window.document)\n"
}
]
}
+5 -1
View File
@@ -37,7 +37,11 @@ KaTeXWidget.prototype.render = function(parent,nextSibling) {
// Render it into a span
var span = this.document.createElement("span");
try {
katex.render(text,span);
if($tw.browser) {
katex.render(text,span);
} else {
span.innerHTML = katex.renderToString(text);
}
} catch(ex) {
span.className = "tc-error";
span.textContent = ex;