From b4e36eff3867d80b644b0045bbf8da2d6bf5068d Mon Sep 17 00:00:00 2001 From: Carlos Villavicencio Date: Wed, 16 May 2018 13:22:54 -0500 Subject: Changed @ for # as highlight symbol --- client/client.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/client/client.js b/client/client.js index d7706cd..e597737 100644 --- a/client/client.js +++ b/client/client.js @@ -18,7 +18,7 @@ var frontpage = [ "Formatting:", "Whitespace is preserved, so source code can be pasted verbatim.", "Surround LaTeX with a dollar sign for inline style $\\zeta(2) = \\pi^2/6$, and two dollars for display. $$\\int_0^1 \\int_0^1 \\frac{1}{1-xy} dx dy = \\frac{\\pi^2}{6}$$", - "For syntax highlight, the first line of the code block should start with @ where can be html, js or any known format", + "For syntax highlight, the first line of the code block must begin with # where can be html, js or any known format", "", "Current Github: https://github.com/hack-chat includes server and client source along with other resources", "", @@ -201,7 +201,18 @@ function pushMessage(args) { textEl.textContent = args.text || ''; textEl.innerHTML = textEl.innerHTML.replace(/(\?|https?:\/\/)\S+?(?=[,.!?:)]?\s|$)/g, parseLinks); - if ($('#parse-latex').checked) { + if ($('#syntax-highlight').checked) { + if (textEl.textContent.indexOf('#') == 0) { + var lang = textEl.textContent.split(/\s+/g)[0].replace('#', ''); + var codeEl = document.createElement('code'); + codeEl.classList.add(lang); + var content = textEl.textContent.replace('#' + lang, ''); + codeEl.textContent = content.trim(); + hljs.highlightBlock(codeEl); + textEl.innerHTML = ''; + textEl.appendChild(codeEl); + } + } else if ($('#parse-latex').checked) { // Temporary hotfix for \rule spamming, see https://github.com/Khan/KaTeX/issues/109 textEl.innerHTML = textEl.innerHTML.replace(/\\rule|\\\\\s*\[.*?\]/g, ''); try { @@ -214,18 +225,6 @@ function pushMessage(args) { } } - if ($('#syntax-highlight').checked) { - if (textEl.textContent.indexOf('@') == 0) { - var lang = textEl.textContent.split('\n', 1)[0].replace('@', ''); - var codeEl = document.createElement('code'); - codeEl.classList.add(lang); - codeEl.textContent = textEl.textContent.replace('@' + lang + '\n', ''); - hljs.highlightBlock(codeEl); - textEl.innerHTML = ''; - textEl.appendChild(codeEl); - } - } - messageEl.appendChild(textEl); // Scroll to bottom -- cgit v1.2.1