summaryrefslogtreecommitdiff
path: root/test/syntax_highlighter_test.rb
diff options
context:
space:
mode:
authorGuillaume Grossetie <ggrossetie@gmail.com>2020-07-17 22:59:04 +0200
committerGitHub <noreply@github.com>2020-07-17 14:59:04 -0600
commitfeb99820cbbfdb1c7cb3f14067a73ec9358d2306 (patch)
treec0906125fbd325c3c93684728954c11b7449f2ed /test/syntax_highlighter_test.rb
parent0861b1d19c522326e4d806be90afd0f2d039ea72 (diff)
resolves #3519 compute highlight line ranges on source block relative to value of start attribute (PR #3701)
Diffstat (limited to 'test/syntax_highlighter_test.rb')
-rw-r--r--test/syntax_highlighter_test.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/syntax_highlighter_test.rb b/test/syntax_highlighter_test.rb
index e1d2702e..d771564c 100644
--- a/test/syntax_highlighter_test.rb
+++ b/test/syntax_highlighter_test.rb
@@ -903,6 +903,75 @@ context 'Syntax Highlighter' do
end
end
+ test 'should line highlight specified lines relative to start value' do
+ input = <<~EOS
+ :source-highlighter: rouge
+
+ [source%linenums,ruby,start=5,highlight=6]
+ ----
+ get {
+ render "Hello, World!"
+ }
+ ----
+ EOS
+
+ expected = <<~EOS.chop
+ <span class="n">get</span> <span class="p">{</span>
+ <span class="hll"> <span class="n">render</span> <span class="s2">"Hello, World!"</span>
+ </span><span class="p">}</span>
+ </pre>
+ EOS
+
+ output = convert_string_to_embedded input, safe: :safe
+ assert_includes output, expected
+ end
+
+ test 'should ignore start attribute when the value is 0' do
+ input = <<~EOS
+ :source-highlighter: rouge
+
+ [source%linenums,ruby,start=0,highlight=6]
+ ----
+ get {
+ render "Hello, World!"
+ }
+ ----
+ EOS
+
+ expected = <<~EOS.chop
+ <span class="n">get</span> <span class="p">{</span>
+ <span class="n">render</span> <span class="s2">"Hello, World!"</span>
+ <span class="p">}</span>
+ </pre>
+ EOS
+
+ output = convert_string_to_embedded input, safe: :safe
+ assert_includes output, expected
+ end
+
+ test 'should not line highlight when the start attribute is greater than highlight' do
+ input = <<~EOS
+ :source-highlighter: rouge
+
+ [source%linenums,ruby,start=7,highlight=6]
+ ----
+ get {
+ render "Hello, World!"
+ }
+ ----
+ EOS
+
+ expected = <<~EOS.chop
+ <span class="n">get</span> <span class="p">{</span>
+ <span class="n">render</span> <span class="s2">"Hello, World!"</span>
+ <span class="p">}</span>
+ </pre>
+ EOS
+
+ output = convert_string_to_embedded input, safe: :safe
+ assert_includes output, expected
+ end
+
test 'should restore callout marks to correct lines if line numbering and line highlighting are enabled' do
[1, 2].each do |highlight|
input = <<~EOS