mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-24 18:24:06 +00:00
highlightjs in nodejs
This commit is contained in:
parent
bb51e399ff
commit
cc85368fd4
@ -7,8 +7,8 @@
|
|||||||
"title": "$:/plugins/tiddlywiki/highlight/highlight.js",
|
"title": "$:/plugins/tiddlywiki/highlight/highlight.js",
|
||||||
"module-type": "library"
|
"module-type": "library"
|
||||||
},
|
},
|
||||||
"prefix": "var hljs;if($tw.browser){\n",
|
"prefix": "var hljs;\n",
|
||||||
"suffix": "}\nexports.hljs = hljs;\n"
|
"suffix": "\nexports.hljs = hljs;\n"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "default.css",
|
"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;
|
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
|
||||||
|
|
||||||
if($tw.browser) {
|
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
|
||||||
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
|
hljs.configure({tabReplace: " "});
|
||||||
hljs.configure({tabReplace: " "});
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeBlockWidget.prototype.postRender = function() {
|
CodeBlockWidget.prototype.postRender = function() {
|
||||||
var domNode = this.domNodes[0];
|
var domNode = this.domNodes[0];
|
||||||
@ -25,6 +23,15 @@ CodeBlockWidget.prototype.postRender = function() {
|
|||||||
domNode.className = this.language.toLowerCase();
|
domNode.className = this.language.toLowerCase();
|
||||||
hljs.highlightBlock(domNode);
|
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…
x
Reference in New Issue
Block a user