summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-07-30 22:31:53 -0700
committerStan Hu <stanhu@gmail.com>2015-07-30 22:37:53 -0700
commit0abe98f0497b667ef85ad4e078ea5c10b5b26ede (patch)
tree4d7eeb19a0a8edaa622a9ae081879df8f3f435a1 /spec
parenta51a3fb8ed92a58b375125b19f75c3d4c545571a (diff)
downloadgitlab-ce-0abe98f0497b667ef85ad4e078ea5c10b5b26ede.tar.gz
Fix multi-line syntax highlighting
HTML span elements only apply to a single line, and in the case of multi-line comments, the highlighting was dropped as a result. Ensure that each line has the proper styling to fix this. Closes #1577
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/blob_helper_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index e49e4e6d5d8..76009c36099 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -6,6 +6,14 @@ describe BlobHelper do
let(:no_context_content) { ":type \"assem\"))" }
let(:blob_content) { "(make-pathname :defaults name\n#{no_context_content}" }
let(:split_content) { blob_content.split("\n") }
+ let(:multiline_content) do
+ %q(
+ def test(input):
+ """This is line 1 of a multi-line comment.
+ This is line 2.
+ """
+ )
+ end
it 'should return plaintext for unknown lexer context' do
result = highlight(blob_name, no_context_content, nowrap: true, continue: false)
@@ -29,5 +37,15 @@ describe BlobHelper do
result = split_content.map{ |content| highlight(blob_name, content, nowrap: true, continue: true) }
expect(result).to eq(expected)
end
+
+ it 'should highlight multi-line comments' do
+ result = highlight(blob_name, multiline_content, nowrap: true, continue: false)
+ html = Nokogiri::HTML(result)
+ lines = html.search('.s')
+ expect(lines.count).to eq(3)
+ expect(lines[0].text).to eq('"""This is line 1 of a multi-line comment.')
+ expect(lines[1].text).to eq(' This is line 2.')
+ expect(lines[2].text).to eq(' """')
+ end
end
end