Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-05-24 06:34:03 +0300
committerStan Hu <stanhu@gmail.com>2015-05-28 00:10:58 +0300
commit0cd73885e6279c2a9a477f59eb76095f4e542858 (patch)
tree351a3bf5667d78aa4027538aa03c4e730d36e649 /app/helpers
parentb222f211c131f471ceae26cff6977881d2d4b4bb (diff)
Fix git blame syntax highlighting when different commits break up lines
Closes #1521
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blob_helper.rb10
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