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…
print-window-tiddler
Jermolene 2017-03-02 09:17:48 +00:00
rodzic 796e59e0dc
commit 28b861451b
2 zmienionych plików z 1 dodań i 2 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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);