@@ -47,101 +47,90 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
47
47
test "generates headers with hovers" do
48
48
assert Templates . link_headings ( "<h2>Foo</h2><h2>Bar</h2>" ) == """
49
49
<h2 id="foo" class="section-heading">
50
- <a href="#foo">
50
+ <a href="#foo" class="hover-link" >
51
51
<i class="ri-link-m" aria-hidden="true"></i>
52
- Foo
53
- </a>
52
+ </a>Foo
54
53
</h2>
55
54
<h2 id="bar" class="section-heading">
56
- <a href="#bar">
55
+ <a href="#bar" class="hover-link" >
57
56
<i class="ri-link-m" aria-hidden="true"></i>
58
- Bar
59
- </a>
57
+ </a>Bar
60
58
</h2>
61
59
"""
62
60
63
61
assert Templates . link_headings ( "<h2>Foo</h2>\n <h2>Bar</h2>" ) == """
64
62
<h2 id="foo" class="section-heading">
65
- <a href="#foo">
63
+ <a href="#foo" class="hover-link" >
66
64
<i class="ri-link-m" aria-hidden="true"></i>
67
- Foo
68
- </a>
65
+ </a>Foo
69
66
</h2>
70
67
71
68
<h2 id="bar" class="section-heading">
72
- <a href="#bar">
69
+ <a href="#bar" class="hover-link" >
73
70
<i class="ri-link-m" aria-hidden="true"></i>
74
- Bar
75
- </a>
71
+ </a>Bar
76
72
</h2>
77
73
"""
78
74
79
75
assert Templates . link_headings ( "<h2></h2><h2>Bar</h2>" ) == """
80
76
<h2></h2><h2 id="bar" class="section-heading">
81
- <a href="#bar">
77
+ <a href="#bar" class="hover-link" >
82
78
<i class="ri-link-m" aria-hidden="true"></i>
83
- Bar
84
- </a>
79
+ </a>Bar
85
80
</h2>
86
81
"""
87
82
88
83
assert Templates . link_headings ( "<h2></h2>\n <h2>Bar</h2>" ) == """
89
84
<h2></h2>
90
85
<h2 id="bar" class="section-heading">
91
- <a href="#bar">
86
+ <a href="#bar" class="hover-link" >
92
87
<i class="ri-link-m" aria-hidden="true"></i>
93
- Bar
94
- </a>
88
+ </a>Bar
95
89
</h2>
96
90
"""
97
91
98
92
assert Templates . link_headings ( "<h2>Foo</h2><h2></h2>" ) ==
99
93
String . trim_trailing ( """
100
94
<h2 id="foo" class="section-heading">
101
- <a href="#foo">
95
+ <a href="#foo" class="hover-link" >
102
96
<i class="ri-link-m" aria-hidden="true"></i>
103
- Foo
104
- </a>
97
+ </a>Foo
105
98
</h2>
106
99
<h2></h2>
107
100
""" )
108
101
109
102
assert Templates . link_headings ( "<h2>Foo</h2>\n <h2></h2>" ) ==
110
103
String . trim_trailing ( """
111
104
<h2 id="foo" class="section-heading">
112
- <a href="#foo">
105
+ <a href="#foo" class="hover-link" >
113
106
<i class="ri-link-m" aria-hidden="true"></i>
114
- Foo
115
- </a>
107
+ </a>Foo
116
108
</h2>
117
109
118
110
<h2></h2>
119
111
""" )
120
112
121
113
assert Templates . link_headings ( "<h3>Foo</h3>" ) == """
122
114
<h3 id="foo" class="section-heading">
123
- <a href="#foo">
115
+ <a href="#foo" class="hover-link" >
124
116
<i class="ri-link-m" aria-hidden="true"></i>
125
- Foo
126
- </a>
117
+ </a>Foo
127
118
</h3>
128
119
"""
129
120
end
130
121
131
122
test "generates headers with unique id's" do
132
123
assert Templates . link_headings ( "<h3>Foo</h3>\n <h3>Foo</h3>" ) == """
133
124
<h3 id="foo" class="section-heading">
134
- <a href="#foo">
125
+ <a href="#foo" class="hover-link" >
135
126
<i class="ri-link-m" aria-hidden="true"></i>
136
- Foo
137
- </a>
127
+ </a>Foo
138
128
</h3>
139
129
140
130
<h3 id="foo-1" class="section-heading">
141
- <a href="#foo-1">
131
+ <a href="#foo-1" class="hover-link" >
142
132
<i class="ri-link-m" aria-hidden="true"></i>
143
- Foo
144
- </a>
133
+ </a>Foo
145
134
</h3>
146
135
"""
147
136
end
@@ -153,10 +142,9 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
153
142
154
143
assert Templates . link_headings ( admonition_block ) == """
155
144
<blockquote><h3 id="foo" class="warning section-heading">
156
- <a href="#foo">
145
+ <a href="#foo" class="hover-link" >
157
146
<i class="ri-link-m" aria-hidden="true"></i>
158
- Foo
159
- </a>
147
+ </a>Foo
160
148
</h3>
161
149
</blockquote>
162
150
"""
@@ -471,10 +459,10 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
471
459
~r{ moduledoc.*Example.*<span class="nc">CompiledWithDocs</span><span class="o">\. </span><span class="n">example</span>.*} ms
472
460
473
461
assert content =~
474
- ~r{ <h2 id="module-example-unicode-escaping" class="section-heading">.*<a href="#module-example-unicode-escaping">.*<i class="ri-link-m" aria-hidden="true"></i>.*Example.* </a>.*</h2>} ms
462
+ ~r{ <h2 id="module-example-unicode-escaping" class="section-heading">.*<a href="#module-example-unicode-escaping" class="hover-link" >.*<i class="ri-link-m" aria-hidden="true"></i>.*</a>.*Example .*</h2>} ms
475
463
476
464
assert content =~
477
- ~r{ <h3 id="module-example-h3-heading" class="section-heading">.*<a href="#module-example-h3-heading">.*<i class="ri-link-m" aria-hidden="true"></i>.*Example H3 heading.*</a> .*</h3>} ms
465
+ ~r{ <h3 id="module-example-h3-heading" class="section-heading">.*<a href="#module-example-h3-heading" class="hover-link" >.*<i class="ri-link-m" aria-hidden="true"></i>.*</a>.* Example H3 heading.*</h3>} ms
478
466
479
467
# Summaries
480
468
assert content =~ ~r{ example/2.*Some example} ms
@@ -567,7 +555,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
567
555
content = get_module_page ( [ CompiledWithDocs ] , context )
568
556
569
557
assert content =~
570
- ~r{ <h3 id="example_with_h3/0-examples" class="section-heading">.*<a href="#example_with_h3/0-examples">.*<i class="ri-link-m" aria-hidden="true"></i>.*Examples.* </a>.*</h3>} ms
558
+ ~r{ <h3 id="example_with_h3/0-examples" class="section-heading">.*<a href="#example_with_h3/0-examples" class="hover-link" >.*<i class="ri-link-m" aria-hidden="true"></i>.*</a>.*Examples .*</h3>} ms
571
559
end
572
560
573
561
test "do not output overlapping functions, causing duplicate IDs" , context do
0 commit comments