mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-30 23:23:02 +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:
		| @@ -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 | ||||||
|   | |||||||
| @@ -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);			 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jermolene
					Jermolene