1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-10-26 05:07:39 +00:00

update highlight plugin to latest ver.

split the latter half of highlight.pack.js into a separate file which
registers all the languages and exports hljs. this is for nodejs
compatibility and mimics the way the highlightjs module works in nodejs.
This commit is contained in:
James Welford Anderson
2015-01-10 08:02:54 +09:00
parent cc85368fd4
commit 903f7db0b2
6 changed files with 84 additions and 31 deletions

View File

@@ -13,8 +13,8 @@ Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5
"use strict";
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
//register languages requires hljs for us
var hljs = require("$:/plugins/tiddlywiki/highlight/registerlanguages.js").hljs;
hljs.configure({tabReplace: " "});
CodeBlockWidget.prototype.postRender = function() {
@@ -29,7 +29,8 @@ CodeBlockWidget.prototype.postRender = function() {
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value);
}
catch(err) {
//alert(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
}
}
};