1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-29 16:53:14 +00:00
TiddlyWiki5/plugins/tiddlywiki/highlight/highlightblock.js
2014-01-12 17:09:24 +00:00

29 lines
741 B
JavaScript

/*\
title: $:/plugins/tiddlywiki/highlight/highlightblock.js
type: application/javascript
module-type: widget
Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5
\*/
(function() {
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
CodeBlockWidget.prototype.postRender = function() {
var self = this,
lang = this.domNodes[0].getElementsByTagName('code')[0].className,
hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
if($tw.browser && lang !== 'no-highlight') {
hljs.tabReplace = ' ';
hljs.highlightBlock(this.domNodes[0]);
}
};
})();