1
0
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:
John Millikin
2018-02-17 17:28:43 -08:00
committed by Alec Thomas
parent 563aadc53c
commit df4ec264da
2 changed files with 23 additions and 6 deletions

View File

@ -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")
}
}