1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 02:19:55 +00:00

highlightjs in nodejs

This commit is contained in:
James Welford Anderson 2015-01-03 02:00:08 +09:00
parent bb51e399ff
commit cc85368fd4
2 changed files with 13 additions and 6 deletions

View File

@ -7,8 +7,8 @@
"title": "$:/plugins/tiddlywiki/highlight/highlight.js",
"module-type": "library"
},
"prefix": "var hljs;if($tw.browser){\n",
"suffix": "}\nexports.hljs = hljs;\n"
"prefix": "var hljs;\n",
"suffix": "\nexports.hljs = hljs;\n"
},
{
"file": "default.css",

View File

@ -14,10 +14,8 @@ Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
if($tw.browser) {
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
hljs.configure({tabReplace: " "});
}
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
hljs.configure({tabReplace: " "});
CodeBlockWidget.prototype.postRender = function() {
var domNode = this.domNodes[0];
@ -25,6 +23,15 @@ CodeBlockWidget.prototype.postRender = function() {
domNode.className = this.language.toLowerCase();
hljs.highlightBlock(domNode);
}
else if(!$tw.browser && this.language && this.language.indexOf("/") == -1 ){
try{
domNode.className = this.language.toLowerCase() + " hljs";
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value);
}
catch(err) {
//alert(err);
}
}
};
})();