diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-19 17:13:37 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-19 17:13:37 +0300 |
commit | 5c7259c7c30228bf85a4efbbddb673046e8d733f (patch) | |
tree | 8a9bdd931bc8f4a6ea5827a759397f71e6e6d8c1 /lib/gitlab/highlight.rb | |
parent | 512bebe21d7f57b691a1c8355581feb64b9b6292 (diff) |
Don't crash when file can't be highlighted
Diffstat (limited to 'lib/gitlab/highlight.rb')
-rw-r--r-- | lib/gitlab/highlight.rb | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index 28cfebef968..4ddb4fea977 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -17,19 +17,13 @@ module Gitlab end def highlight(text, continue: true) - @formatter.format(lex(text, continue: continue)).html_safe + @formatter.format(@lexer.lex(text, continue: continue)).html_safe + rescue + @formatter.format(Rouge::Lexers::PlainText.lex(text)).html_safe end private - def lex(text, continue: true) - if @lexer == Rouge::Lexers::PlainText - @lexer.lex(text) - else - @lexer.lex(text, continue: continue) - end - end - def rouge_formatter(options = {}) options = options.reverse_merge( nowrap: true, |