Commit 5c7259c7 authored by Douwe Maan's avatar Douwe Maan

Don't crash when file can't be highlighted

parent 512bebe2
Pipeline #656770 passed with stage
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment