Skip to content

Commit

Permalink
Merge pull request #7597 from quarto-dev/bugfix/5403
Browse files Browse the repository at this point in the history
fix for kbd shortcode a11y issues
  • Loading branch information
cscheid authored Nov 15, 2023
2 parents 0837bb6 + 7f58958 commit b2e367e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resources/extensions/quarto/kbd/kbd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ return {
default_arg_str = pandoc.utils.stringify(args[1])
end

return pandoc.RawInline('html', '<kbd ' .. kwargs_str .. '>' .. default_arg_str .. '</kbd>')
return pandoc.RawInline('html', '<kbd aria-hidden="true" ' .. kwargs_str .. '>' .. default_arg_str .. '</kbd><span class="visually-hidden">' .. default_arg_str .. '</span>')
elseif quarto.doc.isFormat("asciidoc") and args and #args == 1 then
-- get the 'first' kbd shortcut as we can only produce on shortcut in asciidoc
local shortcutText = pandoc.utils.stringify(args[1]):gsub('-', '+')
Expand Down
13 changes: 13 additions & 0 deletions src/resources/formats/html/_quarto-rules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

// hidden

// https://github.com/quarto-dev/quarto-cli/issues/5403#issuecomment-1533791947
.visually-hidden {
border: 0;
clip: rect(0 0 0 0);
height: auto;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
white-space: nowrap;
}

.hidden {
display: none !important;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/docs/smoke-all/2023/11/15/5403.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
format: html
_quarto:
tests:
html:
ensureHtmlElements:
- ["span.visually-hidden"]
- []
---

{{< kbd Shift-Control-O >}}

0 comments on commit b2e367e

Please sign in to comment.