1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-13 01:10:14 +02:00

Add tabindex="0" to default <pre> wrapper

This commit is contained in:
rhymes
2021-05-23 23:13:00 +02:00
committed by Alec Thomas
parent 8513d9997e
commit c8581d47ee
2 changed files with 3 additions and 3 deletions

View File

@ -131,7 +131,7 @@ var (
} }
defaultPreWrapper = preWrapper{ defaultPreWrapper = preWrapper{
start: func(code bool, styleAttr string) string { start: func(code bool, styleAttr string) string {
return fmt.Sprintf("<pre%s>", styleAttr) return fmt.Sprintf(`<pre tabindex="0"%s>`, styleAttr)
}, },
end: func(code bool) string { end: func(code bool) string {
return "</pre>" return "</pre>"

View File

@ -202,7 +202,7 @@ func TestWithPreWrapper(t *testing.T) {
t.Run("Regular", func(t *testing.T) { t.Run("Regular", func(t *testing.T) {
s := format(New(WithClasses(true))) s := format(New(WithClasses(true)))
assert.Equal(t, s, `<pre class="chroma"><span class="nb">echo</span> FOO</pre>`) assert.Equal(t, s, `<pre tabindex="0" class="chroma"><span class="nb">echo</span> FOO</pre>`)
}) })
t.Run("PreventSurroundingPre", func(t *testing.T) { t.Run("PreventSurroundingPre", func(t *testing.T) {
@ -246,7 +246,7 @@ func TestReconfigureOptions(t *testing.T) {
err = f.Format(&buf, styles.Fallback, it) err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, `<pre class="chroma"><span class="nb">echo</span> FOO</pre>`, buf.String()) assert.Equal(t, `<pre tabindex="0" class="chroma"><span class="nb">echo</span> FOO</pre>`, buf.String())
} }
func TestWriteCssWithAllClasses(t *testing.T) { func TestWriteCssWithAllClasses(t *testing.T) {