Highlight plugin: add static demo

Also clean up some coding style issues
print-window-tiddler
Jermolene 2015-09-11 22:36:30 +01:00
rodzic c80db86b67
commit 3592a9560b
2 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -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"]
} }
} }

Wyświetl plik

@ -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
} }
} }
}; };