mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-16 14:54:51 +00:00
73491f14dd
The technique we were using to configure the library was incorrect.
31 lines
755 B
JavaScript
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);
|
|
}
|
|
};
|
|
|
|
})();
|