Skip to content
Snippets Groups Projects
Commit 2a6969ed authored by Diego Sampaio's avatar Diego Sampaio
Browse files

Fix code highlight

parent 36a5b082
No related branches found
No related tags found
No related merge requests found
......@@ -25,22 +25,25 @@ class Highlight
for part, index in msgParts
# Verify if this part is code
codeMatch = part.match(/```(\w*)[\n\ ]?([\s\S]*?)```+?$/)
codeMatch = part.match(/```(\w*[\n\ ]?)([\s\S]*?)```+?$/)
if codeMatch?
# Process highlight if this part is code
singleLine = codeMatch[0].indexOf('\n') is -1
if singleLine
lang = ''
code = _.unescapeHTML codeMatch[1] + ' ' + codeMatch[2]
code = _.unescapeHTML codeMatch[1] + codeMatch[2]
else
lang = codeMatch[1]
code = _.unescapeHTML codeMatch[2]
if lang not in hljs.listLanguages()
result = hljs.highlightAuto (lang + ' ' + code)
if s.trim(lang) is ''
lang = ''
if s.trim(lang) not in hljs.listLanguages()
result = hljs.highlightAuto (lang + code)
else
result = hljs.highlight lang, code
result = hljs.highlight s.trim(lang), code
token = "=&=#{Random.id()}=&="
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment