summaryrefslogtreecommitdiff
path: root/lib/gitlab/highlight.rb
diff options
context:
space:
mode:
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 = {})