1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Highlight Hotfix

This commit is contained in:
marzavec 2018-05-17 11:13:35 -05:00
parent e64ee88e0f
commit 345dbfec41

View File

@ -201,8 +201,7 @@ function pushMessage(args) {
textEl.textContent = args.text || '';
textEl.innerHTML = textEl.innerHTML.replace(/(\?|https?:\/\/)\S+?(?=[,.!?:)]?\s|$)/g, parseLinks);
if ($('#syntax-highlight').checked) {
if (textEl.textContent.indexOf('#') == 0) {
if ($('#syntax-highlight').checked && textEl.textContent.indexOf('#') == 0) {
var lang = textEl.textContent.split(/\s+/g)[0].replace('#', '');
var codeEl = document.createElement('code');
codeEl.classList.add(lang);
@ -211,7 +210,6 @@ function pushMessage(args) {
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, '');