summaryrefslogtreecommitdiff
path: root/lib/gitlab/markdown
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-10 08:23:10 -0700
committerStan Hu <stanhu@gmail.com>2015-09-10 09:16:27 -0700
commit9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (patch)
treeefe45a503b814013a06d8e77b112b74c6ec4d6a9 /lib/gitlab/markdown
parent1c3c3ba512a85cdf0c09ac4750bcd7955009d6d4 (diff)
downloadgitlab-ce-9d3344adbbfc84ef8abc96366bdfa695293cd6c0.tar.gz
Gracefully handle errors in syntax highlighting by leaving the block unformatted
Closes #2433
Diffstat (limited to 'lib/gitlab/markdown')
-rw-r--r--lib/gitlab/markdown/syntax_highlight_filter.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/markdown/syntax_highlight_filter.rb b/lib/gitlab/markdown/syntax_highlight_filter.rb
index 86f4385753a..f9527c7286e 100644
--- a/lib/gitlab/markdown/syntax_highlight_filter.rb
+++ b/lib/gitlab/markdown/syntax_highlight_filter.rb
@@ -21,7 +21,11 @@ module Gitlab
language = node.attr('class')
code = node.text
- highlighted = block_code(code, language)
+ begin
+ highlighted = block_code(code, language)
+ rescue
+ highlighted = "<pre>#{code}</pre>"
+ end
# Replace the parent `pre` element with the entire highlighted block
node.parent.replace(highlighted)