Commit 1759ea18 authored by Stan Hu's avatar Stan Hu

Merge branch 'patch-71' into 'master'

Update rouge

See merge request gitlab-org/gitlab-ce!29541
parents 868da1d6 4a349944
...@@ -770,7 +770,7 @@ GEM ...@@ -770,7 +770,7 @@ GEM
retriable (3.1.2) retriable (3.1.2)
rinku (2.0.0) rinku (2.0.0)
rotp (2.1.2) rotp (2.1.2)
rouge (3.3.0) rouge (3.4.1)
rqrcode (0.7.0) rqrcode (0.7.0)
chunky_png chunky_png
rqrcode-rails3 (0.1.7) rqrcode-rails3 (0.1.7)
......
...@@ -18,9 +18,10 @@ describe Gitlab::Highlight do ...@@ -18,9 +18,10 @@ describe Gitlab::Highlight do
end end
describe '#highlight' do describe '#highlight' do
let(:plain_text_file_name) { "test.txt" }
let(:plain_text_content) { "plain text contents" }
let(:file_name) { 'test.lisp' } let(:file_name) { 'test.lisp' }
let(:no_context_content) { ":type \"assem\"))" } let(:content) { "(make-pathname :defaults name\n:type \"assem\")" }
let(:content) { "(make-pathname :defaults name\n#{no_context_content}" }
let(:multiline_content) do let(:multiline_content) do
%q( %q(
def test(input): def test(input):
...@@ -32,22 +33,22 @@ describe Gitlab::Highlight do ...@@ -32,22 +33,22 @@ describe Gitlab::Highlight do
it 'highlights' do it 'highlights' do
expected = %Q[<span id="LC1" class="line" lang="common_lisp"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span> expected = %Q[<span id="LC1" class="line" lang="common_lisp"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
<span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>] <span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">)</span></span>]
expect(described_class.highlight(file_name, content)).to eq(expected) expect(described_class.highlight(file_name, content)).to eq(expected)
end end
it 'returns plain version for unknown lexer context' do it 'returns plain version for unknown lexer context' do
result = described_class.highlight(file_name, no_context_content) result = described_class.highlight(plain_text_file_name, plain_text_content)
expect(result).to eq(%[<span id="LC1" class="line" lang="">:type "assem"))</span>]) expect(result).to eq(%[<span id="LC1" class="line" lang="plaintext">plain text contents</span>])
end end
it 'returns plain version for long content' do it 'returns plain version for long content' do
stub_const('Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE', 1) stub_const('Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE', 1)
result = described_class.highlight(file_name, content) result = described_class.highlight(file_name, content)
expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem"))</span>]) expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem")</span>])
end end
it 'highlights multi-line comments' do it 'highlights multi-line comments' do
......
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