Repository navigation
Unused links in HTML output of code chunks #1030
Description
Activity
That HTML is generated by Pandoc (I believe that it is there for line numbers but I'm not 100% sure). We might want to file this issue with Pandoc so they can handle/exclude/annotate as appropriate for all consumers of Pandoc HTML output not just Quarto.
Yes they are used by Pandoc for line numbering. See result of where the
<a>are filled--- title: "Test" format: html --- ```{.r .numberLines} library(tidyverse) mtcars %>% filter(mpg > 30) %>% ggplot(aes(x = mpg, y = disp)) + geom_point() ```
The
aria-hiddenhave been added following a report by @jooyoungseo in jgm/pandoc#6352 as they were not even there before.If there is more to add, I think that would be in Pandoc (even in https://github.com/jgm/skylighting)
Note also that if
code-link: trueis used with a knitr code chunk, the spans won't be here because downlit does not handle yet the line numbering. This is on the TODO and I'll remember to add the missing part if we can't reuse Pandoc numbering.• If the answer is "yes, they are needed", then "provide text within the links that describe the functionality and/or target of that link."
For numberLine = FALSE, keeping the empty anchor with
aria-hiddenwould suffice. If you provide any text for this empty anchor, that content text will be announced before every single code line, which would be very annoying for screen reader users. Note that the code block anchor is not really meaningful until the users want to reference to any specific code line URL. Screen reader users can obtain a code line anchor URL/ID by clicking the current code line via spacebar. When numberLines = TRUE, the visible line numbering is announced to screen readers because each anchor would get a line number as text content. This is an understandable annoyance.Reacted by Mara Averick and Christophe Dervieux- added a parent issue
on Apr 17, 2026 Closing. Based on comments above, the code-line-numbers "off" case is currently handled appropriately.
The above discussion suggests the code-line-numbers "on" case is OK (at least, an "understandable annoyance") but it does currently give an
axe-coreviolation. See #14655 for discussion.Reacted by Christophe Dervieux
This issue came up in the review of the accessible cheatsheets, see mine-cetinkaya-rundel/html-cheatsheets#4 for the original issue.
Suppose you have the following code chunk in a Quarto document with
format: html.The resulting HTML is as follows (with indentation added by me to make it a bit easier to read)
Note that each line of code has an
href. They'rearea-hidden, which is good, but the question is are they needed? Based on the original issue linked above:cc @batpigandme