1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-08 09:36:42 +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, var editor,
updatePreviewDelay = 1000, updatePreviewDelay = 1000,
@@ -35,6 +35,7 @@
console.error('Rendering markdown failed', error); console.error('Rendering markdown failed', error);
} else { } else {
document.getElementById('content').innerHTML = result; document.getElementById('content').innerHTML = result;
slimwiki.View.updateSyntaxHighlighting();
console.log('Updated preview in ' + (new Date().getTime() - start) + ' ms'); console.log('Updated preview in ' + (new Date().getTime() - start) + ' ms');
} }
@@ -76,4 +77,4 @@
init(); 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);