summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2016-06-15 11:52:23 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2016-07-14 10:08:14 -0700
commit7214a221e082c569b4804eb4729e097d4e4b069c (patch)
tree3a108ff9466098f597a754a06dceae0fca9e45ea
parente2c9770e03681edafe14212d3db1035a675ba47d (diff)
downloadgitlab-ce-7214a221e082c569b4804eb4729e097d4e4b069c.tar.gz
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
-rw-r--r--app/helpers/blob_helper.rb5
-rw-r--r--lib/gitlab/highlight.rb16
2 files changed, 8 insertions, 13 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index d639a56f487..39f9f935d31 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -1,6 +1,7 @@
module BlobHelper
- def highlight(blob_name, blob_content, repository: nil, nowrap: false, plain: false)
- Gitlab::Highlight.highlight(blob_name, blob_content, nowrap: nowrap, plain: plain, repository: repository)
+ def highlight(blob_name, blob_content, repository: nil, plain: false)
+ highlighted = Gitlab::Highlight.highlight(blob_name, blob_content, plain: plain, repository: repository)
+ raw %<<pre class="code highlight"><code>#{highlighted}</code></pre>>
end
def no_highlight_files
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb
index 7230a85bc9f..ad928fec970 100644
--- a/lib/gitlab/highlight.rb
+++ b/lib/gitlab/highlight.rb
@@ -1,7 +1,7 @@
module Gitlab
class Highlight
- def self.highlight(blob_name, blob_content, repository: nil, nowrap: true, plain: false)
- new(blob_name, blob_content, nowrap: nowrap, repository: repository).
+ def self.highlight(blob_name, blob_content, repository: nil, plain: false)
+ new(blob_name, blob_content, repository: repository).
highlight(blob_content, continue: false, plain: plain)
end
@@ -13,13 +13,9 @@ module Gitlab
highlight(file_name, blob.data, repository: repository).lines.map!(&:html_safe)
end
- attr_reader :lexer
- def initialize(blob_name, blob_content, repository: nil, nowrap: true)
- @blob_name = blob_name
- @blob_content = blob_content
+ def initialize(blob_name, blob_content, repository: nil)
+ @formatter = rouge_formatter
@repository = repository
- @formatter = rouge_formatter(nowrap: nowrap)
-
@lexer = custom_language || begin
Rouge::Lexer.guess(filename: blob_name, source: blob_content).new
rescue Rouge::Lexer::AmbiguousGuess => e
@@ -51,13 +47,11 @@ module Gitlab
end
def rouge_formatter(options = {})
- options = options.reverse_merge(
+ Rouge::Formatters::HTMLGitlab.new(
cssclass: 'code highlight',
lineanchors: true,
lineanchorsid: 'LC'
)
-
- Rouge::Formatters::HTMLGitlab.new(options)
end
end
end