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
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-01-19 17:13:37 +0300
committerDouwe Maan <douwe@gitlab.com>2016-01-19 17:13:37 +0300
commit5c7259c7c30228bf85a4efbbddb673046e8d733f (patch)
tree8a9bdd931bc8f4a6ea5827a759397f71e6e6d8c1 /lib/gitlab/highlight.rb
parent512bebe21d7f57b691a1c8355581feb64b9b6292 (diff)
Don't crash when file can't be highlighted
Diffstat (limited to 'lib/gitlab/highlight.rb')
-rw-r--r--lib/gitlab/highlight.rb12
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,