From 04a4a0f92eb3ada6e4ec6779db010f7dc4412cb2 Mon Sep 17 00:00:00 2001 From: Talha Mansoor Date: Mon, 15 Apr 2019 22:45:46 +0500 Subject: [PATCH] Add support of language aliases in highlight.js plugin (#3898) listLanguages() returns a list of supported languages. It does not return language aliases. highlight.js has extensive support of language aliases which can be viewed here https://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases But because of using listLanguages(), TW does not take advantage of alias. getLanguage() method on the other hand supports aliases. https://highlightjs.readthedocs.io/en/latest/api.html#getlanguage-name To summarize, now user can use javascript, js or jsx for the code block. getLanguage() will return an object which means highlight.js supports this language. --- plugins/tiddlywiki/highlight/highlightblock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/tiddlywiki/highlight/highlightblock.js b/plugins/tiddlywiki/highlight/highlightblock.js index 22ba0d7d0..7d261fb58 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 && hljs.listLanguages().indexOf(language) !== -1) { + if(language && hljs.getLanguage(language)) { domNode.className = language.toLowerCase() + " hljs"; if($tw.browser && !domNode.isTiddlyWikiFakeDom) { hljs.highlightBlock(domNode);