From 3f75ddd65da6a5753fa90b429ed6f43b4eeae088 Mon Sep 17 00:00:00 2001 From: Albert Ting Date: Wed, 6 Jul 2016 16:47:46 -0400 Subject: Bug 1203960 - Add syntax highlighting to markdown r=dylan Initial implementation by Koosha KM --- js/field.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/field.js') diff --git a/js/field.js b/js/field.js index 063d48c47..5ec7574bc 100644 --- a/js/field.js +++ b/js/field.js @@ -949,6 +949,14 @@ function show_comment_preview(bug_id, refresh) { last_comment_text = comment.value; last_markdown_cb_value = markdown_cb.checked; } + if (markdown_cb.checked) { + var pres = document.getElementById('comment_preview_text').getElementsByTagName("pre"); + for (var i = 0, l = pres.length; i < l; i++) { + if (pres[i].firstChild && pres[i].firstChild.tagName == "CODE") { + hljs.highlightBlock(pres[i].firstChild); + } + } + } }, failure: function(res) { Dom.addClass('comment_preview_loading', 'bz_default_hidden'); -- cgit v1.2.3-24-g4f1b