mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
highlightjs in nodejs
This commit is contained in:
parent
bb51e399ff
commit
cc85368fd4
@ -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",
|
||||
|
@ -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: " "});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user