1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Yet more tweaks to the highlight.js integration

Now we check that the selected language is supported before we invoke
highlight.js; left to its own devices, it crashes…
This commit is contained in:
Jermolene 2017-03-02 09:17:48 +00:00
parent 796e59e0dc
commit 28b861451b
2 changed files with 1 additions and 2 deletions

View File

@ -1,6 +1,5 @@
title: $:/config/HighlightPlugin/TypeMappings/ title: $:/config/HighlightPlugin/TypeMappings/
text/plain:
application/javascript: javascript application/javascript: javascript
application/json: json application/json: json
text/css: css text/css: css

View File

@ -27,7 +27,7 @@ CodeBlockWidget.prototype.postRender = function() {
if(tiddler) { if(tiddler) {
language = tiddler.fields.text || ""; language = tiddler.fields.text || "";
} }
if(language) { if(language && hljs.listLanguages().indexOf(language) !== -1) {
domNode.className = language.toLowerCase() + " hljs"; domNode.className = language.toLowerCase() + " hljs";
if($tw.browser && !domNode.isTiddlyWikiFakeDom) { if($tw.browser && !domNode.isTiddlyWikiFakeDom) {
hljs.highlightBlock(domNode); hljs.highlightBlock(domNode);