Skip to content

Commit

Permalink
Add support for highlight.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
lavigor committed Jul 20, 2017
1 parent 2158996 commit b6c2d68
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion styles/all/template/quickreply_plugins.js
@@ -1,4 +1,4 @@
/* global quickreply, grecaptcha, insert_text, split_lines */
/* global quickreply, grecaptcha, hljs, insert_text, split_lines */
/* jshint -W040 */
;(function($, window, document) {
// do stuff here and use $, window and document safely
Expand Down Expand Up @@ -546,4 +546,20 @@
});
});
}

/***********************/
/* highlight.js Plugin */
/***********************/
$(window).on('load', function() {
if (hljs && hljs.highlightBlock) {
var qrHighlightCode = function(e, elements) {
elements.find('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
};

quickreply.$.qrPosts.on('qr_completed', qrHighlightCode);
quickreply.$.mainForm.on('ajax_submit_preview', qrHighlightCode);
}
});
})(jQuery, window, document);

0 comments on commit b6c2d68

Please sign in to comment.