-
-
Notifications
You must be signed in to change notification settings - Fork 996
Screen reader accessibility improvement for highlighted codeblock of html output #1833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@atusy, it still does not work. Haha, I do not understand why this simple thing takes so long time. Any advice would be greatly appreciated. |
|
FYI, the js itself works perfectly when I render with |
|
@atusy, thanks very much! However, here is a very picky issue. I have tested and confirmed that neither This is very weird because it works successfully if I move the script down after body (of course, after removing the dom load dispatch). Humm... I think I need to dig into how to tackle this tacky problem. |
|
What do you mean by the empty anchors? I see following result with the inspector. <a href="#cb1-1" aria-hidden="true"></a> |
|
@atusy, I am so excited to tell you that we have made it! Please kindly ignore the previous comment (it turned out the issue caused by a screen reader bug delay caught by the previous buffer history). With several testing with various combinations of browsers and screen readers, this fix is now working welll and safely! :) Thanks very much again. I will add a line to |
|
Congrats and thank you for crediting me!! |
yihui
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'll make some cosmetic changes and merge the PR. Thank you!
for (i in elements) to for (i = 0; i < elements.length; i++) because the former may loop into other properties of `elements`
…his function in the (far) future, so do not export this function yet, unless other package authors ask for it
* rstudio/master: (61 commits) make metadata available before running pre_knit (rstudio#1855) fix rstudio#1815: apply the lua filters pagebreak.lua and latex-div.lua to beamer_presentation require the data-latex attribute on fenced Div's again: rstudio#1779 (comment) start the next version CRAN release v2.3 fold any code blocks with the class `foldable` for html_document output (rstudio#1835) fix rstudio#1828: add aria-hidden = "true" to empty <a> tags in highlighted code blocks generated by Pandoc to improve screen reader accessibility (rstudio#1833) add a news item for rstudio#1832 roxygenize no need to turn on --file-scope or actually write the split content into files if the split content is of length < 2 eliminate renumber_footnotes option only test two pandoc versions (devel and RStudio version) and upgrade default to 2.7.3 (rstudio#1846) close rstudio#1838: test more R versions on Travis (rstudio#1845) renumber_footnotes output format option add the <div class="kable-table"> only when the output format is HTML, otherwise the div will be converted to a LaTeX environment, leading to the bug https://stackoverflow.com/q/62340425/559676 change name of file_scope argument to references_scope re-roxygenize Add `publish_site()` function for "one-button" publishing of R Markdown websites. Enable use of pandoc --file-scope for input files originating from multiple Rmds (rstudio#1837) Added missing lang attribute to ioslides_presentation template (rstudio#1841) ...
This PR addresses #1828, and have been tested and confirmed with many hours of testing with various combinations of different screen readers and browsers.
Current Issue
When code highlight is used for html output, screen reader users hear unnecessary and annoying information in codeblock, such as "#cb1-1," "#cb3-1," "#cb5-1," and "#cb5-2."
This is because the code anchor (
<a>) produced bypandoc skyligtinghas empty content, and eachidattribute value is read out by screen readers.To avoid this issue, we need to put
aria-hidden = "true"per each empty<a>code anchor within "source code" class.While the
pandocfix will be already made and will be available in next version see pandoc/issue#6352, we need a backword solution towards current and previouspandocversions (between v2.7.3 and v2.9.2.1).I have written a simple js that can address this issue, and this simple fix can dramatically improve the screen reader accessibility for any
html_document-like output.Testing File
Output to Screen Readers (without this fix)