summaryrefslogtreecommitdiff
path: root/lib/gitlab/highlight.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-01-14 22:28:07 +0100
committerDouwe Maan <douwe@gitlab.com>2016-01-14 22:28:07 +0100
commit8dfad143d44af4896ff6c71e8a42ad32b69ad593 (patch)
tree4f1379b9f00c26a89197629a586b323c820c37a5 /lib/gitlab/highlight.rb
parent83e4fc188b22731d89106b4da28f11bf5509c116 (diff)
downloadgitlab-ce-8dfad143d44af4896ff6c71e8a42ad32b69ad593.tar.gz
Add inline diff markers in highlighted diffs.
Diffstat (limited to 'lib/gitlab/highlight.rb')
-rw-r--r--lib/gitlab/highlight.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb
index 02e097eca3d..a5b041687e3 100644
--- a/lib/gitlab/highlight.rb
+++ b/lib/gitlab/highlight.rb
@@ -7,6 +7,13 @@ module Gitlab
formatter.format(lexer.lex(blob_content, continue: continue)).html_safe
end
+ def self.highlight_lines(repository, ref, file_name)
+ blob = repository.blob_at(ref, file_name)
+ return [] unless blob
+
+ highlight(file_name, blob.data).lines.map!(&:html_safe)
+ end
+
private
def self.rouge_formatter(options = {})