1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-02-05 13:05:18 +02:00

Fix extra semicolon in tabWidthStyle

Needed after changes in #636
This commit is contained in:
Siavash Askari Nasr 2022-06-13 20:52:33 +04:30 committed by Alec Thomas
parent 806ca29650
commit c78b8a6a03
2 changed files with 13 additions and 1 deletions

View File

@ -381,7 +381,7 @@ func (f *Formatter) styleAttr(styles map[chroma.TokenType]string, tt chroma.Toke
func (f *Formatter) tabWidthStyle() string {
if f.tabWidth != 0 && f.tabWidth != 8 {
return fmt.Sprintf("; -moz-tab-size: %[1]d; -o-tab-size: %[1]d; tab-size: %[1]d", f.tabWidth)
return fmt.Sprintf("-moz-tab-size: %[1]d; -o-tab-size: %[1]d; tab-size: %[1]d", f.tabWidth)
}
return ""
}

View File

@ -108,6 +108,18 @@ func TestTableLineNumberNewlines(t *testing.T) {
</span>`)
}
func TestTabWidthStyle(t *testing.T) {
f := New(TabWidth(4), WithClasses(false))
it, err := lexers.Get("bash").Tokenise(nil, "echo FOO")
assert.NoError(t, err)
var buf bytes.Buffer
err = f.Format(&buf, styles.Fallback, it)
assert.NoError(t, err)
assert.Regexp(t, `<pre.*style=".*background-color:[^;]+;-moz-tab-size:4;-o-tab-size:4;tab-size:4[^"]*".+`, buf.String())
}
func TestWithCustomCSS(t *testing.T) {
f := New(WithClasses(false), WithCustomCSS(map[chroma.TokenType]string{chroma.Line: `display: inline;`}))
it, err := lexers.Get("bash").Tokenise(nil, "echo FOO")