Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-09-10 18:23:10 +0300
committerStan Hu <stanhu@gmail.com>2015-09-10 19:16:27 +0300
commit9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (patch)
treeefe45a503b814013a06d8e77b112b74c6ec4d6a9 /lib
parent1c3c3ba512a85cdf0c09ac4750bcd7955009d6d4 (diff)
Gracefully handle errors in syntax highlighting by leaving the block unformatted
Closes #2433
Diffstat (limited to 'lib')
-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)