summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-05-23 23:34:03 -0400
committerStan Hu <stanhu@gmail.com>2015-05-27 14:10:58 -0700
commit0cd73885e6279c2a9a477f59eb76095f4e542858 (patch)
tree351a3bf5667d78aa4027538aa03c4e730d36e649 /app
parentb222f211c131f471ceae26cff6977881d2d4b4bb (diff)
downloadgitlab-ce-0cd73885e6279c2a9a477f59eb76095f4e542858.tar.gz
Fix git blame syntax highlighting when different commits break up lines
Closes #1521
Diffstat (limited to 'app')
-rw-r--r--app/helpers/blob_helper.rb10
-rw-r--r--app/views/projects/blame/show.html.haml2
2 files changed, 6 insertions, 6 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 9fe5f82f02f..50df3801703 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -1,6 +1,6 @@
module BlobHelper
- def highlight(blob_name, blob_content, nowrap = false)
- formatter = Rugments::Formatters::HTML.new(
+ def highlight(blob_name, blob_content, nowrap: false, continue: false)
+ @formatter ||= Rugments::Formatters::HTML.new(
nowrap: nowrap,
cssclass: 'code highlight',
lineanchors: true,
@@ -8,11 +8,11 @@ module BlobHelper
)
begin
- lexer = Rugments::Lexer.guess(filename: blob_name, source: blob_content)
- result = formatter.format(lexer.lex(blob_content)).html_safe
+ @lexer ||= Rugments::Lexer.guess(filename: blob_name, source: blob_content).new
+ result = @formatter.format(@lexer.lex(blob_content, continue: continue)).html_safe
rescue
lexer = Rugments::Lexers::PlainText
- result = formatter.format(lexer.lex(blob_content)).html_safe
+ result = @formatter.format(lexer.lex(blob_content)).html_safe
end
result
diff --git a/app/views/projects/blame/show.html.haml b/app/views/projects/blame/show.html.haml
index 462f5b7afb0..8019c7f4569 100644
--- a/app/views/projects/blame/show.html.haml
+++ b/app/views/projects/blame/show.html.haml
@@ -32,5 +32,5 @@
%code
:erb
<% lines.each do |line| %>
- <%= highlight(@blob.name, line, true).html_safe %>
+ <%= highlight(@blob.name, line, nowrap: true, continue: true).html_safe %>
<% end %>