From 9d3344adbbfc84ef8abc96366bdfa695293cd6c0 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 10 Sep 2015 08:23:10 -0700 Subject: Gracefully handle errors in syntax highlighting by leaving the block unformatted Closes #2433 --- lib/gitlab/markdown/syntax_highlight_filter.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') 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 = "
#{code}
" + end # Replace the parent `pre` element with the entire highlighted block node.parent.replace(highlighted) -- cgit v1.2.3