1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 01:50:28 +00:00
TiddlyWiki5/plugins/tiddlywiki/highlight/highlightblock.js
Jermolene 73491f14dd Update highlight plugin configuration to support tabs
The technique we were using to configure the library was incorrect.
2014-11-06 13:27:24 +00:00

31 lines
755 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;
if($tw.browser) {
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs;
hljs.configure({tabReplace: " "});
}
CodeBlockWidget.prototype.postRender = function() {
var domNode = this.domNodes[0];
if($tw.browser && this.document !== $tw.fakeDocument && this.language) {
domNode.className = this.language.toLowerCase();
hljs.highlightBlock(domNode);
}
};
})();