Commit 7214a221 authored by http://jneen.net/'s avatar http://jneen.net/

kill the nowrap option

the <pre><code> wrapping is *always* used by the helper, and *never* by
anywhere else, so pull the wrapping into the helper
parent e2c9770e
module BlobHelper module BlobHelper
def highlight(blob_name, blob_content, repository: nil, nowrap: false, plain: false) def highlight(blob_name, blob_content, repository: nil, plain: false)
Gitlab::Highlight.highlight(blob_name, blob_content, nowrap: nowrap, plain: plain, repository: repository) highlighted = Gitlab::Highlight.highlight(blob_name, blob_content, plain: plain, repository: repository)
raw %<<pre class="code highlight"><code>#{highlighted}</code></pre>>
end end
def no_highlight_files def no_highlight_files
......
module Gitlab module Gitlab
class Highlight class Highlight
def self.highlight(blob_name, blob_content, repository: nil, nowrap: true, plain: false) def self.highlight(blob_name, blob_content, repository: nil, plain: false)
new(blob_name, blob_content, nowrap: nowrap, repository: repository). new(blob_name, blob_content, repository: repository).
highlight(blob_content, continue: false, plain: plain) highlight(blob_content, continue: false, plain: plain)
end end
...@@ -13,13 +13,9 @@ module Gitlab ...@@ -13,13 +13,9 @@ module Gitlab
highlight(file_name, blob.data, repository: repository).lines.map!(&:html_safe) highlight(file_name, blob.data, repository: repository).lines.map!(&:html_safe)
end end
attr_reader :lexer def initialize(blob_name, blob_content, repository: nil)
def initialize(blob_name, blob_content, repository: nil, nowrap: true) @formatter = rouge_formatter
@blob_name = blob_name
@blob_content = blob_content
@repository = repository @repository = repository
@formatter = rouge_formatter(nowrap: nowrap)
@lexer = custom_language || begin @lexer = custom_language || begin
Rouge::Lexer.guess(filename: blob_name, source: blob_content).new Rouge::Lexer.guess(filename: blob_name, source: blob_content).new
rescue Rouge::Lexer::AmbiguousGuess => e rescue Rouge::Lexer::AmbiguousGuess => e
...@@ -51,13 +47,11 @@ module Gitlab ...@@ -51,13 +47,11 @@ module Gitlab
end end
def rouge_formatter(options = {}) def rouge_formatter(options = {})
options = options.reverse_merge( Rouge::Formatters::HTMLGitlab.new(
cssclass: 'code highlight', cssclass: 'code highlight',
lineanchors: true, lineanchors: true,
lineanchorsid: 'LC' lineanchorsid: 'LC'
) )
Rouge::Formatters::HTMLGitlab.new(options)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment