mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +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:
parent
cbe2a53d6a
commit
63c174d7ed
@ -143,8 +143,10 @@ Object.defineProperty(TW_Element.prototype, "outerHTML", {
|
||||
for(var s in this.style) {
|
||||
style.push(s + ":" + this.style[s] + ";");
|
||||
}
|
||||
if(style.length > 0) {
|
||||
output.push(" style='",style.join(""),"'")
|
||||
}
|
||||
}
|
||||
output.push(">");
|
||||
if($tw.config.htmlVoidElements.indexOf(this.tag) === -1) {
|
||||
output.push(this.innerHTML);
|
||||
|
@ -2,9 +2,7 @@ title: HelloThere
|
||||
|
||||
This is a TiddlyWiki plugin for mathematical typesetting based on KaTeX from Khan Academy.
|
||||
|
||||
It is completely self-contained, and doesn't need an Internet connection in order to work.
|
||||
|
||||
//This first version of the plugin cannot be used to generate static content under Node.js, but that capability will come in a future update. (Note that you can still use it when running the client-server configuration under Node.js).//
|
||||
It is completely self-contained, and doesn't need an Internet connection in order to work. It works both in the browser and under Node.js.
|
||||
|
||||
! Installation
|
||||
|
||||
|
@ -10,6 +10,11 @@
|
||||
],
|
||||
"build": {
|
||||
"index": [
|
||||
"--rendertiddler","$:/core/save/all","katexdemo.html","text/plain"]
|
||||
"--rendertiddler","$:/core/save/all","katexdemo.html","text/plain"],
|
||||
"static": [
|
||||
"--rendertiddler","$:/core/templates/static.template.html","static.html","text/plain",
|
||||
"--rendertiddler","$:/core/templates/alltiddlers.template.html","alltiddlers.html","text/plain",
|
||||
"--rendertiddlers","[!is[system]]","$:/core/templates/static.tiddler.html","static","text/plain",
|
||||
"--rendertiddler","$:/core/templates/static.template.css","static/static.css","text/plain"]
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
if($tw.browser) {
|
||||
katex.render(text,span);
|
||||
} else {
|
||||
span.innerHTML = katex.renderToString(text);
|
||||
}
|
||||
} catch(ex) {
|
||||
span.className = "tc-error";
|
||||
span.textContent = ex;
|
||||
|
Loading…
Reference in New Issue
Block a user