mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-28 22:16:15 +10:00
Don't crash when file can't be highlighted
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user