diff options
author | Stan Hu <stanhu@gmail.com> | 2015-09-10 18:23:10 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-09-10 19:16:27 +0300 |
commit | 9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (patch) | |
tree | efe45a503b814013a06d8e77b112b74c6ec4d6a9 /lib | |
parent | 1c3c3ba512a85cdf0c09ac4750bcd7955009d6d4 (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.rb | 6 |
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) |