mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
markup: Add tabindex="0" to default <pre> wrapper
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
This commit is contained in:
@@ -154,7 +154,7 @@ description
|
||||
c.Assert(got, qt.Contains, `<h2 id="神真美好-2">神真美好</h2>`, qt.Commentf(got))
|
||||
|
||||
// Code fences
|
||||
c.Assert(got, qt.Contains, "<div class=\"highlight\"><pre class=\"chroma\"><code class=\"language-bash\" data-lang=\"bash\">LINE1\n</code></pre></div>")
|
||||
c.Assert(got, qt.Contains, "<div class=\"highlight\"><pre tabindex=\"0\" class=\"chroma\"><code class=\"language-bash\" data-lang=\"bash\">LINE1\n</code></pre></div>")
|
||||
c.Assert(got, qt.Contains, "Code Fences No Lexer</h2>\n<pre><code class=\"language-moo\" data-lang=\"moo\">LINE1\n</code></pre>")
|
||||
|
||||
// Extensions
|
||||
@@ -389,7 +389,7 @@ LINE5
|
||||
|
||||
result := convertForConfig(c, cfg, `echo "Hugo Rocks!"`, "bash")
|
||||
// TODO(bep) there is a whitespace mismatch (\n) between this and the highlight template func.
|
||||
c.Assert(result, qt.Equals, `<div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">"Hugo Rocks!"</span>
|
||||
c.Assert(result, qt.Equals, `<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="nb">echo</span> <span class="s2">"Hugo Rocks!"</span>
|
||||
</code></pre></div>`)
|
||||
result = convertForConfig(c, cfg, `echo "Hugo Rocks!"`, "unknown")
|
||||
c.Assert(result, qt.Equals, "<pre><code class=\"language-unknown\" data-lang=\"unknown\">echo "Hugo Rocks!"\n</code></pre>")
|
||||
@@ -400,7 +400,7 @@ LINE5
|
||||
cfg.NoClasses = false
|
||||
|
||||
result := convertForConfig(c, cfg, lines, `bash {linenos=table,hl_lines=[2 "4-5"],linenostart=3}`)
|
||||
c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre class=\"chroma\"><code><span class")
|
||||
c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre tabindex=\"0\" class=\"chroma\"><code><span class")
|
||||
c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">4")
|
||||
|
||||
result = convertForConfig(c, cfg, lines, "bash {linenos=inline,hl_lines=[2]}")
|
||||
|
Reference in New Issue
Block a user