mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-05 13:05:18 +02:00
parent
806ca29650
commit
c78b8a6a03
@ -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 ""
|
||||
}
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user