[#369] fix rendering spec files

This commit is contained in:
Alexander Machehin 2015-02-28 11:39:22 +05:00
parent 4da6b1a84a
commit 5aa06da501
1 changed files with 8 additions and 2 deletions

View File

@ -110,9 +110,9 @@ module GitHelper
def blob_highlight(blob)
return if blob.nil? || blob.data.blank?
result = if blob.mime_type == 'text/rpm-spec'
Pygments.highlight blob.data, lexer: 'spec', options: {linenos: true}
Pygments.highlight blob.data, highlight_options.merge(lexer: 'spec')
else
blob.colorize(options: {linenos: true, lineanchors: 'lc', linespans: 'ln', anchorlinenos: true})
blob.colorize(highlight_options)
end
result.present? ? result.html_safe : blob.data
rescue MentosError, Yajl::ParseError => e
@ -130,4 +130,10 @@ module GitHelper
rescue MentosError, Yajl::ParseError => e
text.html_safe
end
protected
def highlight_options
@highlight ||= { options: { linenos: true, lineanchors: 'lc', linespans: 'ln', anchorlinenos: true }}
end
end