mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Highlight plugin: add static demo
Also clean up some coding style issues
This commit is contained in:
parent
c80db86b67
commit
3592a9560b
@ -11,6 +11,11 @@
|
|||||||
],
|
],
|
||||||
"build": {
|
"build": {
|
||||||
"index": [
|
"index": [
|
||||||
"--rendertiddler","$:/core/save/all","highlightdemo.html","text/plain"]
|
"--rendertiddler","$:/core/save/all","highlightdemo.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"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ CodeBlockWidget.prototype.postRender = function() {
|
|||||||
if($tw.browser && this.document !== $tw.fakeDocument && this.language) {
|
if($tw.browser && this.document !== $tw.fakeDocument && this.language) {
|
||||||
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 ){
|
} else if(!$tw.browser && this.language && this.language.indexOf("/") === -1 ){
|
||||||
try{
|
try {
|
||||||
domNode.className = this.language.toLowerCase() + " hljs";
|
domNode.className = this.language.toLowerCase() + " hljs";
|
||||||
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value);
|
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value);
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
//can't easily tell if a language is registered or not in the packed version of hightlight.js
|
// Can't easily tell if a language is registered or not in the packed version of hightlight.js,
|
||||||
//so we silently fail and the codeblock remains unchanged
|
// so we silently fail and the codeblock remains unchanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user