1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-06 08:37:31 +02:00

Updating syntax highlighting after preview was updated

This commit is contained in:
til-schneider
2015-12-22 12:52:31 +01:00
parent 40389176cf
commit e8e9d8de75
2 changed files with 20 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
(function(CodeMirror) {
(function(window, document, console, CodeMirror) {
var editor,
updatePreviewDelay = 1000,
@@ -35,6 +35,7 @@
console.error('Rendering markdown failed', error);
} else {
document.getElementById('content').innerHTML = result;
slimwiki.View.updateSyntaxHighlighting();
console.log('Updated preview in ' + (new Date().getTime() - start) + ' ms');
}
@@ -76,4 +77,4 @@
init();
})(CodeMirror);
})(window, document, console, CodeMirror);

View File

@@ -1 +1,17 @@
hljs.initHighlightingOnLoad();
(function(window, document, hljs) {
window.slimwiki = window.slimwiki || {};
window.slimwiki.View = {
updateSyntaxHighlighting: updateSyntaxHighlighting
};
updateSyntaxHighlighting();
function updateSyntaxHighlighting() {
var blocks = document.getElementById('content').querySelectorAll('pre code');
Array.prototype.forEach.call(blocks, hljs.highlightBlock);
}
})(window, document, hljs);