Skip to content

Commit

Permalink
Fix extra semicolon in tabWidthStyle
Browse files Browse the repository at this point in the history
Needed after changes in #636
  • Loading branch information
CIAvash authored and alecthomas committed Jun 13, 2022
1 parent 806ca29 commit c78b8a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion formatters/html/html.go
Expand Up @@ -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 ""
}
Expand Down
12 changes: 12 additions & 0 deletions formatters/html/html_test.go
Expand Up @@ -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")
Expand Down

0 comments on commit c78b8a6

Please sign in to comment.