From 3592a9560bf7e5571acffe22aaf955214c1df264 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 11 Sep 2015 22:36:30 +0100 Subject: [PATCH] Highlight plugin: add static demo Also clean up some coding style issues --- editions/highlightdemo/tiddlywiki.info | 7 ++++++- plugins/tiddlywiki/highlight/highlightblock.js | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/editions/highlightdemo/tiddlywiki.info b/editions/highlightdemo/tiddlywiki.info index de3b00a24..3e824764b 100644 --- a/editions/highlightdemo/tiddlywiki.info +++ b/editions/highlightdemo/tiddlywiki.info @@ -11,6 +11,11 @@ ], "build": { "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"] } } diff --git a/plugins/tiddlywiki/highlight/highlightblock.js b/plugins/tiddlywiki/highlight/highlightblock.js index d1947b6a2..a2187e8d7 100644 --- a/plugins/tiddlywiki/highlight/highlightblock.js +++ b/plugins/tiddlywiki/highlight/highlightblock.js @@ -23,14 +23,14 @@ CodeBlockWidget.prototype.postRender = function() { if($tw.browser && this.document !== $tw.fakeDocument && this.language) { domNode.className = this.language.toLowerCase(); hljs.highlightBlock(domNode); - } else if(!$tw.browser && this.language && this.language.indexOf("/") == -1 ){ - try{ + } 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) { - //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 + // 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 } } };