Skip to content

Commit ab0ad33

Browse files
author
William Breathitt Gray
authored
Improve accessibility by nesting bottom footnotes inside footer element (#2688)
This adds semantic meaning to the footnotes organization and improves accessibility by aiding disabled users who rely on assistive devices such as screen readers which utilize semantic tags such as the footer element in order to navigate properly. The hr element is semantically defined as representing a paragraph-level thematic break. Now that the footnotes are descendants of the footer element, the hr element originally preceding the footnotes list is no longer necessary (footnotes are no longer paragraph-level content) and thus replaced. However, the footer element is given the class "footnotes" to allow for styling, so the following CSS could be used to provide a stylistically equivalent visible border separating the footnotes from the content if so desired: .footnotes { border-top: 2px groove gray; } Test snapshots are also updated to reflect the new footer elements.
1 parent 2b5c3d0 commit ab0ad33

7 files changed

+21
-8
lines changed

components/markdown/src/markdown.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ fn convert_footnotes_to_github_style(old_events: &mut Vec<Event>) {
304304
return;
305305
}
306306

307-
old_events.push(Event::Html("<hr><ol class=\"footnotes-list\">\n".into()));
307+
old_events
308+
.push(Event::Html("<footer class=\"footnotes\">\n<ol class=\"footnotes-list\">\n".into()));
308309

309310
// Step 2: retain only footnotes which was actually referenced
310311
footnotes.retain(|f| match f.first() {
@@ -394,7 +395,7 @@ fn convert_footnotes_to_github_style(old_events: &mut Vec<Event>) {
394395
});
395396

396397
old_events.extend(footnotes);
397-
old_events.push(Event::Html("</ol>\n".into()));
398+
old_events.push(Event::Html("</ol>\n</footer>\n".into()));
398399
}
399400

400401
pub fn markdown_to_html(

components/markdown/src/snapshots/markdown__markdown__tests__def_before_use.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ source: components/markdown/src/markdown.rs
33
expression: html
44
---
55
<p>There is footnote definition?<sup class="footnote-reference" id="fr-1-1"><a href="#fn-1">1</a></sup></p>
6-
<hr><ol class="footnotes-list">
6+
<footer class="footnotes">
7+
<ol class="footnotes-list">
78
<li id="fn-1">
89
<p>It's before the reference. <a href="#fr-1-1">↩</a></p>
910
</li>
1011
</ol>
12+
</footer>

components/markdown/src/snapshots/markdown__markdown__tests__footnote_inside_footnote.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ source: components/markdown/src/markdown.rs
33
expression: html
44
---
55
<p>This text has a footnote<sup class="footnote-reference" id="fr-1-1"><a href="#fn-1">1</a></sup></p>
6-
<hr><ol class="footnotes-list">
6+
<footer class="footnotes">
7+
<ol class="footnotes-list">
78
<li id="fn-1">
89
<p>But the footnote has another footnote<sup class="footnote-reference" id="fr-2-1"><a href="#fn-2">2</a></sup>. <a href="#fr-1-1">↩</a></p>
910
</li>
1011
<li id="fn-2">
1112
<p>That's it. <a href="#fr-2-1">↩</a></p>
1213
</li>
1314
</ol>
15+
</footer>

components/markdown/src/snapshots/markdown__markdown__tests__multiple_refs.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ source: components/markdown/src/markdown.rs
33
expression: html
44
---
55
<p>This text has two<sup class="footnote-reference" id="fr-1-1"><a href="#fn-1">1</a></sup> identical footnotes<sup class="footnote-reference" id="fr-1-2"><a href="#fn-1">1</a></sup></p>
6-
<hr><ol class="footnotes-list">
6+
<footer class="footnotes">
7+
<ol class="footnotes-list">
78
<li id="fn-1">
89
<p>So one is present. <a href="#fr-1-1">↩</a> <a href="#fr-1-2">↩2</a></p>
910
</li>
1011
</ol>
12+
</footer>

components/markdown/src/snapshots/markdown__markdown__tests__reordered_footnotes.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ source: components/markdown/src/markdown.rs
33
expression: html
44
---
55
<p>This text has two<sup class="footnote-reference" id="fr-2-1"><a href="#fn-2">1</a></sup> footnotes<sup class="footnote-reference" id="fr-1-1"><a href="#fn-1">2</a></sup></p>
6-
<hr><ol class="footnotes-list">
6+
<footer class="footnotes">
7+
<ol class="footnotes-list">
78
<li id="fn-2">
89
<p>But they are <a href="#fr-2-1">↩</a></p>
910
</li>
1011
<li id="fn-1">
1112
<p>not sorted. <a href="#fr-1-1">↩</a></p>
1213
</li>
1314
</ol>
15+
</footer>

components/markdown/src/snapshots/markdown__markdown__tests__single_footnote.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ source: components/markdown/src/markdown.rs
33
expression: html
44
---
55
<p>This text has a footnote<sup class="footnote-reference" id="fr-1-1"><a href="#fn-1">1</a></sup></p>
6-
<hr><ol class="footnotes-list">
6+
<footer class="footnotes">
7+
<ol class="footnotes-list">
78
<li id="fn-1">
89
<p>But it is meaningless. <a href="#fr-1-1">↩</a></p>
910
</li>
1011
</ol>
12+
</footer>

components/markdown/tests/snapshots/markdown__github_style_footnotes.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ expression: body
88
<p>This text has two<sup class="footnote-reference" id="fr-5-1"><a href="#fn-5">5</a></sup> identical footnotes<sup class="footnote-reference" id="fr-5-2"><a href="#fn-5">5</a></sup></p>
99
<p>This text has a footnote<sup class="footnote-reference" id="fr-7-1"><a href="#fn-7">6</a></sup></p>
1010
<p>Footnotes can also be referenced with identifiers<sup class="footnote-reference" id="fr-first-1"><a href="#fn-first">8</a></sup>.</p>
11-
<hr><ol class="footnotes-list">
11+
<footer class="footnotes">
12+
<ol class="footnotes-list">
1213
<li id="fn-1">
1314
<p>But it is meaningless. <a href="#fr-1-1">↩</a></p>
1415
</li>
@@ -34,3 +35,4 @@ expression: body
3435
<p>Like this: <code>[^first]</code>. <a href="#fr-first-1">↩</a></p>
3536
</li>
3637
</ol>
38+
</footer>

0 commit comments

Comments
 (0)