summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGuillaume Grossetie <ggrossetie@gmail.com>2019-07-10 10:30:10 +0200
committerGuillaume Grossetie <ggrossetie@gmail.com>2019-07-16 12:53:38 +0200
commit0cba81c0ecc71f411153b1f2a2952c07125217f9 (patch)
tree48198eb6c5e9feb42065a8b539a00344b2d60216 /spec
parent1def071991dddf6a1500c84d9e53a0edd64d45a1 (diff)
downloadgitlab-ce-0cba81c0ecc71f411153b1f2a2952c07125217f9.tar.gz
Enable section anchors
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/asciidoc_spec.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb
index ff002acbd35..5293732ead1 100644
--- a/spec/lib/gitlab/asciidoc_spec.rb
+++ b/spec/lib/gitlab/asciidoc_spec.rb
@@ -96,6 +96,75 @@ module Gitlab
end
end
+ context 'with passthrough' do
+ it 'removes non heading ids' do
+ input = <<~ADOC
+ ++++
+ <h2 id="foo">Title</h2>
+ ++++
+ ADOC
+
+ output = <<~HTML
+ <h2>Title</h2>
+ HTML
+
+ expect(render(input, context)).to include(output.strip)
+ end
+ end
+
+ context 'with section anchors' do
+ it 'preserves ids and links' do
+ input = <<~ADOC
+ = Title
+
+ == First section
+
+ This is the first section.
+
+ == Second section
+
+ This is the second section.
+
+ == Thunder ⚡ !
+
+ This is the third section.
+ ADOC
+
+ output = <<~HTML
+ <h1>Title</h1>
+ <div>
+ <h2 id="user-content-first-section">
+ <a class="anchor" href="#user-content-first-section"></a>First section</h2>
+ <div>
+ <div>
+ <p>This is the first section.</p>
+ </div>
+ </div>
+ </div>
+ <div>
+ <h2 id="user-content-second-section">
+ <a class="anchor" href="#user-content-second-section"></a>Second section</h2>
+ <div>
+ <div>
+ <p>This is the second section.</p>
+ </div>
+ </div>
+ </div>
+ <div>
+ <h2 id="user-content-thunder">
+ <a class="anchor" href="#user-content-thunder"></a>Thunder ⚡ !</h2>
+ <div>
+ <div>
+ <p>This is the third section.</p>
+ </div>
+ </div>
+ </div>
+ HTML
+
+ expect(render(input, context)).to include(output.strip)
+ end
+ end
+
context 'with checklist' do
it 'preserves classes' do
input = <<~ADOC