mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	highlightjs in nodejs
This commit is contained in:
		| @@ -7,8 +7,8 @@ | ||||
| 				"title": "$:/plugins/tiddlywiki/highlight/highlight.js", | ||||
| 				"module-type": "library" | ||||
| 			}, | ||||
| 			"prefix": "var hljs;if($tw.browser){\n", | ||||
| 			"suffix": "}\nexports.hljs = hljs;\n" | ||||
| 			"prefix": "var hljs;\n", | ||||
| 			"suffix": "\nexports.hljs = hljs;\n" | ||||
| 		}, | ||||
| 		{ | ||||
| 			"file": "default.css", | ||||
|   | ||||
| @@ -14,10 +14,8 @@ Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5 | ||||
|  | ||||
| var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock; | ||||
|  | ||||
| if($tw.browser) { | ||||
| 	var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs; | ||||
| 	hljs.configure({tabReplace: "    "});	 | ||||
| } | ||||
| var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs; | ||||
| hljs.configure({tabReplace: "    "});	 | ||||
|  | ||||
| CodeBlockWidget.prototype.postRender = function() { | ||||
| 	var domNode = this.domNodes[0]; | ||||
| @@ -25,6 +23,15 @@ CodeBlockWidget.prototype.postRender = function() { | ||||
| 		domNode.className = this.language.toLowerCase(); | ||||
| 		hljs.highlightBlock(domNode); | ||||
| 	} | ||||
| 	else if(!$tw.browser && this.language && this.language.indexOf("/") == -1 ){ | ||||
| 		try{ | ||||
| 			domNode.className = this.language.toLowerCase() + " hljs"; | ||||
| 			domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value); | ||||
| 		} | ||||
| 		catch(err) { | ||||
| 			//alert(err); | ||||
| 		} | ||||
| 	}	 | ||||
| }; | ||||
|  | ||||
| })(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 James Welford Anderson
					James Welford Anderson