Add tabindex to highlight template func markup #7194
Comments
You can copy this into your project: |
|
Never mind that comment, I see that the shortcode is just delegating to the internal template func. |
|
The internal function wraps the code in a div tag. hugo/markup/highlight/highlight.go Lines 88 to 92 in f0266e2 Would it be possible to move this to the short code? That way users have more flexibility in wrapping the generated |
|
Hey again, I was thinking of this again since #8280 with attribute lists for code fences. Would it be possible to have a way to specify default attributes for code fences? |
Currently the generated `<pre>` element isn't fully accessible as it can't be focused by keyboard users. To make this fully accessible, the attribute `tabindex="0"` should be added to the `<pre>` tag. Closes gohugoio#7194
|
Browsers like Firefox will allow scrollable elements to be tab focusable by default, so maybe it's a browser-level issue? I've been injecting tabindexes with Edit: Oh yeah. And while using tabindex, Firefox is the one complaining about accessibility. By forcing tabindex in ALL elements (even if not scrollable), the issue becomes "Focusable elements should have interactive semantics". |
Currently the generated `<pre>` element isn't fully accessible as it can't be focused by keyboard users. To make this fully accessible, the attribute `tabindex="0"` should be added to the `<pre>` tag. Closes #7194
Code blocks generated through the
{{ highlight }}shortcode or through the use of Markdown code fences should have thetabindex="0"attribute, allowing them to be tab focusable. This is good for accessibility; see here.I've searched through the docs and I cannot find any way to set this attribute myself in my own site, since the
highlightshortcode is (apparently) built-in to Hugo, so I don't think there is any way to do this outside of a change to Hugo itself.The text was updated successfully, but these errors were encountered: