Skip to content

Commit c8581d4

Browse files
rhymesalecthomas
authored andcommitted
Add tabindex="0" to default <pre> wrapper
1 parent 8513d99 commit c8581d4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: formatters/html/html.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ var (
131131
}
132132
defaultPreWrapper = preWrapper{
133133
start: func(code bool, styleAttr string) string {
134-
return fmt.Sprintf("<pre%s>", styleAttr)
134+
return fmt.Sprintf(`<pre tabindex="0"%s>`, styleAttr)
135135
},
136136
end: func(code bool) string {
137137
return "</pre>"

Diff for: formatters/html/html_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func TestWithPreWrapper(t *testing.T) {
202202

203203
t.Run("Regular", func(t *testing.T) {
204204
s := format(New(WithClasses(true)))
205-
assert.Equal(t, s, `<pre class="chroma"><span class="nb">echo</span> FOO</pre>`)
205+
assert.Equal(t, s, `<pre tabindex="0" class="chroma"><span class="nb">echo</span> FOO</pre>`)
206206
})
207207

208208
t.Run("PreventSurroundingPre", func(t *testing.T) {
@@ -246,7 +246,7 @@ func TestReconfigureOptions(t *testing.T) {
246246
err = f.Format(&buf, styles.Fallback, it)
247247

248248
assert.NoError(t, err)
249-
assert.Equal(t, `<pre class="chroma"><span class="nb">echo</span> FOO</pre>`, buf.String())
249+
assert.Equal(t, `<pre tabindex="0" class="chroma"><span class="nb">echo</span> FOO</pre>`, buf.String())
250250
}
251251

252252
func TestWriteCssWithAllClasses(t *testing.T) {

0 commit comments

Comments
 (0)