From 28b861451bf3f19d7acc64e79a8a45b97aa9029b Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 2 Mar 2017 09:17:48 +0000 Subject: [PATCH] Yet more tweaks to the highlight.js integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we check that the selected language is supported before we invoke highlight.js; left to its own devices, it crashes… --- plugins/tiddlywiki/highlight/TypeMappings.multids | 1 - plugins/tiddlywiki/highlight/highlightblock.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/tiddlywiki/highlight/TypeMappings.multids b/plugins/tiddlywiki/highlight/TypeMappings.multids index 0bf0ef87e..9e07d07bd 100644 --- a/plugins/tiddlywiki/highlight/TypeMappings.multids +++ b/plugins/tiddlywiki/highlight/TypeMappings.multids @@ -1,6 +1,5 @@ title: $:/config/HighlightPlugin/TypeMappings/ -text/plain: application/javascript: javascript application/json: json text/css: css diff --git a/plugins/tiddlywiki/highlight/highlightblock.js b/plugins/tiddlywiki/highlight/highlightblock.js index e5049936b..22ba0d7d0 100644 --- a/plugins/tiddlywiki/highlight/highlightblock.js +++ b/plugins/tiddlywiki/highlight/highlightblock.js @@ -27,7 +27,7 @@ CodeBlockWidget.prototype.postRender = function() { if(tiddler) { language = tiddler.fields.text || ""; } - if(language) { + if(language && hljs.listLanguages().indexOf(language) !== -1) { domNode.className = language.toLowerCase() + " hljs"; if($tw.browser && !domNode.isTiddlyWikiFakeDom) { hljs.highlightBlock(domNode);