mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-07 17:17:05 +02:00
Updating syntax highlighting after preview was updated
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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);
|
||||||
|
Reference in New Issue
Block a user