1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-18 07:44:51 +00:00
TiddlyWiki5/plugins/tiddlywiki/highlight/highlightblock.js

29 lines
742 B
JavaScript
Raw Normal View History

/*\
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]);
}
};
})();