mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-15 14:21:23 +00:00
Update KaTeX wrapper to support operation under Node.js
Now we can generate static HTML containing mathematical typesetting
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user