Don't crash when file can't be highlighted

This commit is contained in:
Douwe Maan 2016-01-19 15:13:37 +01:00
parent 512bebe21d
commit 5c7259c7c3

View file

@ -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,