Skip to content

Commit c4b3e00

Browse files
committed
Revert "Revert hover link approach to fix markup of headings containing links (#1752)"
This reverts commit c4ef075.
1 parent 6af8835 commit c4b3e00

File tree

9 files changed

+54
-50
lines changed

9 files changed

+54
-50
lines changed

assets/css/content/admonition.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108

109109
.content-inner blockquote :is(h3, h4):is(.warning, .error, .info, .neutral, .tip) :is(a, a:visited) {
110110
color: inherit;
111-
text-decoration-color: currentColor;
112111
}
113112

114113
@media screen and (max-width: 768px) {

assets/css/content/cheatsheet.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@
3636
/* h3 */
3737

3838
.page-cheatmd .content-inner h3 {
39-
color: var(--main);
4039
margin: 0 0 1em;
4140
font-weight: 400;
4241
overflow: hidden;
4342
}
4443

45-
.page-cheatmd .content-inner h3 :is(a, a:visited) {
44+
.page-cheatmd .content-inner h3 a {
4645
color: var(--main);
47-
text-decoration: none;
4846
}
4947

5048
.page-cheatmd .content-inner h3.section-heading a.hover-link {

assets/css/content/general.css

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,23 @@
132132
}
133133

134134
.content-inner .section-heading a {
135-
color: var(--links);
135+
color: var(--links);
136+
text-decoration: none;
136137
display: inline-block;
137138
}
138139

139140
.content-inner .section-heading a.no-underline {
140141
color: var(--links);
141142
}
142143

143-
.content-inner .section-heading a.hover-link {
144-
text-decoration: none;
145-
}
146-
147144
.content-inner .section-heading i {
148-
--icon-size: 16px;
149-
--icon-spacing: 5px;
150-
font-size: var(--icon-size);
145+
font-size: 16px;
151146
margin-top: .1em;
152-
margin-left: calc(-1 * (var(--icon-size) + var(--icon-spacing)));
153-
padding-right: var(--icon-spacing);
147+
margin-left: -21px;
154148
opacity: 0;
155149
}
156150

157-
.content-inner .section-heading:hover i {
151+
.content-inner .section-heading a:is(:hover, :focus) i {
158152
opacity: 1;
159153
}
160154

formatters/html/dist/html-elixir-LBZZ5PJG.css renamed to formatters/html/dist/html-elixir-FV6ADR4N.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formatters/html/dist/html-erlang-IUKA2KES.css renamed to formatters/html/dist/html-erlang-TEM7XJXV.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ex_doc/formatter/html/templates.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,10 @@ defmodule ExDoc.Formatter.HTML.Templates do
302302

303303
"""
304304
<#{tag} id="#{prefix}#{id}" class="#{class_attribute}">
305-
<a href="##{prefix}#{id}" class="hover-link">
305+
<a href="##{prefix}#{id}">
306306
<i class="ri-link-m" aria-hidden="true"></i>
307-
</a>#{title}
307+
#{title}
308+
</a>
308309
</#{tag}>
309310
"""
310311
end

test/ex_doc/formatter/epub/templates_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
6060
assert content =~ ~r{<h1 id="content">\s*CompiledWithDocs\s*}
6161

6262
assert content =~
63-
~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
63+
~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
6464

6565
assert content =~
66-
~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
66+
~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
6767

6868
assert content =~
6969
~r{moduledoc.*Example.*<samp class="nc">CompiledWithDocs</samp><samp class="o">\.</samp><samp class="n">example</samp>.*}ms

test/ex_doc/formatter/html/templates_test.exs

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,90 +47,101 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
4747
test "generates headers with hovers" do
4848
assert Templates.link_headings("<h2>Foo</h2><h2>Bar</h2>") == """
4949
<h2 id="foo" class="section-heading">
50-
<a href="#foo" class="hover-link">
50+
<a href="#foo">
5151
<i class="ri-link-m" aria-hidden="true"></i>
52-
</a>Foo
52+
Foo
53+
</a>
5354
</h2>
5455
<h2 id="bar" class="section-heading">
55-
<a href="#bar" class="hover-link">
56+
<a href="#bar">
5657
<i class="ri-link-m" aria-hidden="true"></i>
57-
</a>Bar
58+
Bar
59+
</a>
5860
</h2>
5961
"""
6062

6163
assert Templates.link_headings("<h2>Foo</h2>\n<h2>Bar</h2>") == """
6264
<h2 id="foo" class="section-heading">
63-
<a href="#foo" class="hover-link">
65+
<a href="#foo">
6466
<i class="ri-link-m" aria-hidden="true"></i>
65-
</a>Foo
67+
Foo
68+
</a>
6669
</h2>
6770
6871
<h2 id="bar" class="section-heading">
69-
<a href="#bar" class="hover-link">
72+
<a href="#bar">
7073
<i class="ri-link-m" aria-hidden="true"></i>
71-
</a>Bar
74+
Bar
75+
</a>
7276
</h2>
7377
"""
7478

7579
assert Templates.link_headings("<h2></h2><h2>Bar</h2>") == """
7680
<h2></h2><h2 id="bar" class="section-heading">
77-
<a href="#bar" class="hover-link">
81+
<a href="#bar">
7882
<i class="ri-link-m" aria-hidden="true"></i>
79-
</a>Bar
83+
Bar
84+
</a>
8085
</h2>
8186
"""
8287

8388
assert Templates.link_headings("<h2></h2>\n<h2>Bar</h2>") == """
8489
<h2></h2>
8590
<h2 id="bar" class="section-heading">
86-
<a href="#bar" class="hover-link">
91+
<a href="#bar">
8792
<i class="ri-link-m" aria-hidden="true"></i>
88-
</a>Bar
93+
Bar
94+
</a>
8995
</h2>
9096
"""
9197

9298
assert Templates.link_headings("<h2>Foo</h2><h2></h2>") ==
9399
String.trim_trailing("""
94100
<h2 id="foo" class="section-heading">
95-
<a href="#foo" class="hover-link">
101+
<a href="#foo">
96102
<i class="ri-link-m" aria-hidden="true"></i>
97-
</a>Foo
103+
Foo
104+
</a>
98105
</h2>
99106
<h2></h2>
100107
""")
101108

102109
assert Templates.link_headings("<h2>Foo</h2>\n<h2></h2>") ==
103110
String.trim_trailing("""
104111
<h2 id="foo" class="section-heading">
105-
<a href="#foo" class="hover-link">
112+
<a href="#foo">
106113
<i class="ri-link-m" aria-hidden="true"></i>
107-
</a>Foo
114+
Foo
115+
</a>
108116
</h2>
109117
110118
<h2></h2>
111119
""")
112120

113121
assert Templates.link_headings("<h3>Foo</h3>") == """
114122
<h3 id="foo" class="section-heading">
115-
<a href="#foo" class="hover-link">
123+
<a href="#foo">
116124
<i class="ri-link-m" aria-hidden="true"></i>
117-
</a>Foo
125+
Foo
126+
</a>
118127
</h3>
119128
"""
120129
end
121130

122131
test "generates headers with unique id's" do
123132
assert Templates.link_headings("<h3>Foo</h3>\n<h3>Foo</h3>") == """
124133
<h3 id="foo" class="section-heading">
125-
<a href="#foo" class="hover-link">
134+
<a href="#foo">
126135
<i class="ri-link-m" aria-hidden="true"></i>
127-
</a>Foo
136+
Foo
137+
</a>
128138
</h3>
129139
130140
<h3 id="foo-1" class="section-heading">
131-
<a href="#foo-1" class="hover-link">
141+
<a href="#foo-1">
132142
<i class="ri-link-m" aria-hidden="true"></i>
133-
</a>Foo
143+
Foo
144+
</a>
134145
</h3>
135146
"""
136147
end
@@ -142,9 +153,10 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
142153

143154
assert Templates.link_headings(admonition_block) == """
144155
<blockquote><h3 id="foo" class="warning section-heading">
145-
<a href="#foo" class="hover-link">
156+
<a href="#foo">
146157
<i class="ri-link-m" aria-hidden="true"></i>
147-
</a>Foo
158+
Foo
159+
</a>
148160
</h3>
149161
</blockquote>
150162
"""
@@ -459,10 +471,10 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
459471
~r{moduledoc.*Example.*<span class="nc">CompiledWithDocs</span><span class="o">\.</span><span class="n">example</span>.*}ms
460472

461473
assert content =~
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
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
463475

464476
assert content =~
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
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
466478

467479
# Summaries
468480
assert content =~ ~r{example/2.*Some example}ms
@@ -555,7 +567,7 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
555567
content = get_module_page([CompiledWithDocs], context)
556568

557569
assert content =~
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
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
559571
end
560572

561573
test "do not output overlapping functions, causing duplicate IDs", context do

test/ex_doc/formatter/html_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,10 @@ defmodule ExDoc.Formatter.HTMLTest do
365365
assert content =~ ~r{<title>README [^<]*</title>}
366366

367367
assert content =~
368-
~r{<h2 id="header-sample" class="section-heading">.*<a href="#header-sample" class="hover-link">.*<i class="ri-link-m" aria-hidden="true"></i>.*</a>.*<code(\sclass="inline")?>Header</code> sample.*</h2>}ms
368+
~r{<h2 id="header-sample" class="section-heading">.*<a href="#header-sample">.*<i class="ri-link-m" aria-hidden="true"></i>.*<code(\sclass="inline")?>Header</code> sample.*</a>.*</h2>}ms
369369

370370
assert content =~
371-
~r{<h2 id="more-than" class="section-heading">.*<a href="#more-than" class="hover-link">.*<i class="ri-link-m" aria-hidden="true"></i>.*</a>.*more &gt; than.*</h2>}ms
371+
~r{<h2 id="more-than" class="section-heading">.*<a href="#more-than">.*<i class="ri-link-m" aria-hidden="true"></i>.*more &gt; than.*</a>.*</h2>}ms
372372

373373
assert content =~ ~r{<a href="RandomError.html"><code(\sclass="inline")?>RandomError</code>}
374374

0 commit comments

Comments
 (0)