mirror of
https://github.com/alecthomas/chroma.git
synced 2025-07-01 00:35:06 +02:00
Render HTML class prefixes.
This commit is contained in:
committed by
Alec Thomas
parent
563aadc53c
commit
df4ec264da
@ -1,6 +1,7 @@
|
||||
package html
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
@ -75,3 +76,19 @@ func TestFormatterStyleToCSS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestClassPrefix(t *testing.T) {
|
||||
wantPrefix := "some-prefix-"
|
||||
f := New(WithClasses(), ClassPrefix(wantPrefix))
|
||||
for st := range chroma.StandardTypes {
|
||||
if got := f.class(st); !strings.HasPrefix(got, wantPrefix) {
|
||||
t.Errorf("f.class(%v): %q should have a class prefix", st, got)
|
||||
}
|
||||
}
|
||||
|
||||
var styleBuf bytes.Buffer
|
||||
f.WriteCSS(&styleBuf, styles.Fallback)
|
||||
if !strings.Contains(styleBuf.String(), ".some-prefix-chroma ") {
|
||||
t.Error("Stylesheets should have a class prefix")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user