Skip to content

Commit

Permalink
Improve accessibility by nesting bottom footnotes inside footer element
Browse files Browse the repository at this point in the history
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;
    }
  • Loading branch information
vilhelmgray committed Nov 6, 2024
1 parent 2b5c3d0 commit 9e2f215
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/markdown/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ fn convert_footnotes_to_github_style(old_events: &mut Vec<Event>) {
return;
}

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

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

old_events.extend(footnotes);
old_events.push(Event::Html("</ol>\n".into()));
old_events.push(Event::Html("</ol>\n</footer>\n".into()));
}

pub fn markdown_to_html(
Expand Down

0 comments on commit 9e2f215

Please sign in to comment.