diff options
author | Stan Hu <stanhu@gmail.com> | 2015-09-10 08:23:10 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-09-10 09:16:27 -0700 |
commit | 9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (patch) | |
tree | efe45a503b814013a06d8e77b112b74c6ec4d6a9 /lib/gitlab/markdown | |
parent | 1c3c3ba512a85cdf0c09ac4750bcd7955009d6d4 (diff) | |
download | gitlab-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.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) |