diff options
author | Robert Speicher <robert@gitlab.com> | 2016-04-28 21:33:50 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-04-28 21:33:50 +0000 |
commit | 10f84f99cb663faae37139495f547bb68bd8aced (patch) | |
tree | dbddf53a57112c569de0033958c96985c9d7d1c5 /lib | |
parent | 73990df32fb5151fd3a887010e0fef7a5a54cfef (diff) | |
parent | ad99404d2588e182a115d89b0b457d957e8ca7b6 (diff) | |
download | gitlab-ce-10f84f99cb663faae37139495f547bb68bd8aced.tar.gz |
Merge branch 'zj-large-files-no-highlight' into 'master'
Properly handle bigger files
Closes #3967
See merge request !3718
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/highlight.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index cac76442321..280120b0f9e 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -1,7 +1,8 @@ module Gitlab class Highlight - def self.highlight(blob_name, blob_content, nowrap: true) - new(blob_name, blob_content, nowrap: nowrap).highlight(blob_content, continue: false) + def self.highlight(blob_name, blob_content, nowrap: true, plain: false) + new(blob_name, blob_content, nowrap: nowrap). + highlight(blob_content, continue: false, plain: plain) end def self.highlight_lines(repository, ref, file_name) @@ -17,8 +18,12 @@ module Gitlab @lexer = Rouge::Lexer.guess(filename: blob_name, source: blob_content).new rescue Rouge::Lexers::PlainText end - def highlight(text, continue: true) - @formatter.format(@lexer.lex(text, continue: continue)).html_safe + def highlight(text, continue: true, plain: false) + if plain + @formatter.format(Rouge::Lexers::PlainText.lex(text)).html_safe + else + @formatter.format(@lexer.lex(text, continue: continue)).html_safe + end rescue @formatter.format(Rouge::Lexers::PlainText.lex(text)).html_safe end |