Skip to content

Unused links in HTML output of code chunks #1030

@mine-cetinkaya-rundel

Description

@mine-cetinkaya-rundel

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.

library(tidyverse)
mtcars %>%
  filter(mpg > 30) %>%
  ggplot(aes(x = mpg, y = disp)) +
  geom_point()

The resulting HTML is as follows (with indentation added by me to make it a bit easier to read)

<div class="sourceCode cell-code" id="cb5">
   <pre class="sourceCode r code-with-copy">
      <code class="sourceCode r">
         <span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>mtcars <span class="sc">%&gt;%</span></span>
         <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>  <span class="fu">filter</span>(mpg <span class="sc">&gt;</span> <span class="dv">30</span>) <span class="sc">%&gt;%</span></span>
         <span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a>  <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x =</span> mpg, <span class="at">y =</span> disp)) <span class="sc">+</span></span>
         <span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>  <span class="fu">geom_point</span>()</span>. 
      </code>
      <button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button>
   </pre>
</div>

Note that each line of code has an href. They're area-hidden, which is good, but the question is are they needed? Based on the original issue linked above:

  • If the answer is "yes, they are needed", then "provide text within the links that describe the functionality and/or target of that link."
  • If the answer is "no, they are not needed", then "remove the empty link".

cc @batpigandme

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions