kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Switch highlight plugin under Node.js to use DOM rather than raw HTML
Hi @welford I wondered if you could kindly review this commit, since you authored the original code? Before this commit, I was running into a crash when running `prerelease-bld.sh` from `build.jermolene.github.io`, caused by using raw HTML for the highlighted block. Switching to the fake dom seems to fix things, but I’d like a second pair of eyes.print-window-tiddler
rodzic
292d653880
commit
4be5f0abe8
|
@ -27,15 +27,11 @@ CodeBlockWidget.prototype.postRender = function() {
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
language = tiddler.fields.text || "";
|
language = tiddler.fields.text || "";
|
||||||
}
|
}
|
||||||
if($tw.browser && this.document !== $tw.fakeDocument && language) {
|
if(language) {
|
||||||
domNode.className = language.toLowerCase();
|
|
||||||
hljs.highlightBlock(domNode);
|
|
||||||
} else if(!$tw.browser && language && language.indexOf("/") === -1 ){
|
|
||||||
try {
|
try {
|
||||||
domNode.className = language.toLowerCase() + " hljs";
|
domNode.className = language.toLowerCase() + " hljs";
|
||||||
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(language, this.getAttribute("code")).value);
|
hljs.highlightBlock(domNode);
|
||||||
}
|
} catch(err) {
|
||||||
catch(err) {
|
|
||||||
// Can't easily tell if a language is registered or not in the packed version of hightlight.js,
|
// Can't easily tell if a language is registered or not in the packed version of hightlight.js,
|
||||||
// so we silently fail and the codeblock remains unchanged
|
// so we silently fail and the codeblock remains unchanged
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue