diff options
author | Mark Chao <mchao@gitlab.com> | 2018-09-06 12:34:25 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-10-30 15:44:55 +0800 |
commit | 39ae9a59a59615092fbef189466f37c34f4a7fb1 (patch) | |
tree | c8611265f8fb290cbce92f04cadb593b531165ee /app/helpers/blob_helper.rb | |
parent | 32f9cf8ce3dd337bf3b1683c5872171c253f0d27 (diff) | |
download | gitlab-ce-39ae9a59a59615092fbef189466f37c34f4a7fb1.tar.gz |
Make Highlight accept language param
This replaces the repository param.
This allows more flexiblity as sometimes we have highlight content
not related to repository. Sometimes we know ahead of time the language
of the content. Lastly language determination seems better fit as a
logic in the Blob class.
`repository` param is only used to determine the language, which seems
to be the responsiblity of Blob.
Diffstat (limited to 'app/helpers/blob_helper.rb')
-rw-r--r-- | app/helpers/blob_helper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index ff7f1e3a9aa..52cf9d12287 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module BlobHelper - def highlight(blob_name, blob_content, repository: nil, plain: false) - plain ||= blob_content.length > Blob::MAXIMUM_TEXT_HIGHLIGHT_SIZE - highlighted = Gitlab::Highlight.highlight(blob_name, blob_content, plain: plain, repository: repository) + def highlight(file_name, file_content, language: nil, plain: false) + plain ||= file_content.length > Blob::MAXIMUM_TEXT_HIGHLIGHT_SIZE + highlighted = Gitlab::Highlight.highlight(file_name, file_content, plain: plain, language: language) raw %(<pre class="code highlight"><code>#{highlighted}</code></pre>) end |