diff options
author | Stan Hu <stanhu@gmail.com> | 2015-05-23 23:34:03 -0400 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-05-27 14:10:58 -0700 |
commit | 0cd73885e6279c2a9a477f59eb76095f4e542858 (patch) | |
tree | 351a3bf5667d78aa4027538aa03c4e730d36e649 /app/helpers/blob_helper.rb | |
parent | b222f211c131f471ceae26cff6977881d2d4b4bb (diff) | |
download | gitlab-ce-0cd73885e6279c2a9a477f59eb76095f4e542858.tar.gz |
Fix git blame syntax highlighting when different commits break up lines
Closes #1521
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r-- | app/helpers/blob_helper.rb | 10 |
1 files changed, 5 insertions, 5 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 |