From ac6d0c1bb3c69d199044716171497537552e7400 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Fri, 21 Aug 2015 22:42:01 -0300 Subject: [PATCH] Do not remove first word of block if it is single line. Fixes #536 --- packages/rocketchat-highlight/highlight.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/rocketchat-highlight/highlight.coffee b/packages/rocketchat-highlight/highlight.coffee index 815f59e984d2..55468747368d 100644 --- a/packages/rocketchat-highlight/highlight.coffee +++ b/packages/rocketchat-highlight/highlight.coffee @@ -27,8 +27,15 @@ class Highlight codeMatch = part.match(/```(\w*)[\n\ ]?([\s\S]*?)```+?/) if codeMatch? # Process highlight if this part is code - lang = codeMatch[1] - code = _.unescapeHTML codeMatch[2] + singleLine = codeMatch[0].indexOf('\n') is -1 + + if singleLine + lang = '' + code = _.unescapeHTML codeMatch[1] + ' ' + codeMatch[2] + else + lang = codeMatch[1] + code = _.unescapeHTML codeMatch[2] + if lang not in hljs.listLanguages() result = hljs.highlightAuto code else