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

Changed @ for # as highlight symbol

This commit is contained in:
Carlos Villavicencio 2018-05-16 13:22:54 -05:00
parent ffd4c36830
commit b4e36eff38

View File

@ -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 @<format> where <format> can be html, js or any known format",
"For syntax highlight, the first line of the code block must begin with #<format> where <format> 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