Skip to content

Commit

Permalink
Remove aria-label from <section>s.
Browse files Browse the repository at this point in the history
My inspiration for these included the `aria-label` because the notes did
not have a label like `Note: ` or a heading on them; these do, though.
Keep the `aria-role` so screen readers present notes distinctively the
same way the visual presentation is set off.

Fix README: remove `aria-label` from there as well
  • Loading branch information
chriskrycho committed Apr 26, 2024
1 parent 8c899a3 commit 2eabe4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Some text.
—and rewrites the Markdown to this:

```html
<section class="note" aria-label="Note" aria-role="note">
<section class="note" aria-role="note">

This is some material we want to provide more emphasis for, because it is
important in some way!
Expand All @@ -25,7 +25,7 @@ important in some way!

Some text.

<section class="note" aria-label="Note" aria-role="note">
<section class="note" aria-role="note">

## Some subject

Expand Down
30 changes: 15 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use pulldown_cmark_to_cmark::cmark;
/// Spits out Markdown like this:
///
/// ```markdown
/// <section class="note" aria-label="Note" aria-role="note">
/// <section class="note" aria-role="note">
///
/// This is a note.
///
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn rewrite(text: &str) -> String {
events.extend([
SoftBreak,
SoftBreak,
Html(r#"<section class="note" aria-label="Note" aria-role="note">"#.into()),
Html(r#"<section class="note" aria-role="note">"#.into()),
SoftBreak,
SoftBreak,
Start(Tag::Paragraph),
Expand All @@ -93,7 +93,7 @@ pub fn rewrite(text: &str) -> String {
events.extend([
SoftBreak,
SoftBreak,
Html(r#"<section class="note" aria-label="Note" aria-role="note">"#.into()),
Html(r#"<section class="note" aria-role="note">"#.into()),
SoftBreak,
SoftBreak,
heading,
Expand Down Expand Up @@ -152,7 +152,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<p>Note: This is some text.\nIt keeps going.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<p>Note: This is some text.\nIt keeps going.</p>\n</section>"
);
}

Expand All @@ -172,7 +172,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<p>Note: This is some text.\nIt keeps going.</p>\n</section>\n<p>This is regular text.</p>\n<blockquote>\n<p>This is a blockquote.</p>\n</blockquote>\n"
"<section class=\"note\" aria-role=\"note\">\n<p>Note: This is some text.\nIt keeps going.</p>\n</section>\n<p>This is regular text.</p>\n<blockquote>\n<p>This is a blockquote.</p>\n</blockquote>\n"
);
}

Expand All @@ -182,7 +182,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<p>Note: This is noted.</p>\n</section>"
"<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n<section class=\"note\" aria-role=\"note\">\n<p>Note: This is noted.</p>\n</section>"
);
}

Expand All @@ -192,7 +192,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<p>Note: This is noted.</p>\n</section>\n<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n"
"<section class=\"note\" aria-role=\"note\">\n<p>Note: This is noted.</p>\n</section>\n<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n"
);
}

Expand All @@ -202,7 +202,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -212,7 +212,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h2>Header</h2>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h2>Header</h2>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -222,7 +222,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h3>Header</h3>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h3>Header</h3>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -232,7 +232,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h4>Header</h4>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h4>Header</h4>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -242,7 +242,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h5>Header</h5>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h5>Header</h5>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -252,7 +252,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h6>Header</h6>\n<p>And then some note content.</p>\n</section>"
"<section class=\"note\" aria-role=\"note\">\n<h6>Header</h6>\n<p>And then some note content.</p>\n</section>"
);
}

Expand All @@ -262,7 +262,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>\n<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n"
"<section class=\"note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>\n<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n"
);
}

Expand All @@ -272,7 +272,7 @@ mod tests {
let processed = rewrite(text);
assert_eq!(
render_markdown(&processed),
"<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n<section class=\"note\" aria-label=\"Note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>"
"<blockquote>\n<p>This is quoted.</p>\n</blockquote>\n<section class=\"note\" aria-role=\"note\">\n<h1>Header</h1>\n<p>And then some note content.</p>\n</section>"
);
}

Expand Down

0 comments on commit 2eabe4e

Please sign in to comment.