mirror of
https://github.com/alecthomas/chroma.git
synced 2025-03-17 20:58:08 +02:00
Ensure class names from default set exist.
This commit is contained in:
parent
2ca426a8d1
commit
80d3b96869
@ -246,11 +246,14 @@ func (f *Formatter) styleToCSS(style *chroma.Style) map[chroma.TokenType]string
|
||||
classes := map[chroma.TokenType]string{}
|
||||
bg := style.Get(chroma.Background)
|
||||
// Convert the style.
|
||||
for _, t := range style.Types() {
|
||||
for t := range chroma.StandardTypes {
|
||||
entry := style.Get(t)
|
||||
if t != chroma.Background {
|
||||
entry = entry.Sub(bg)
|
||||
}
|
||||
if entry.IsZero() {
|
||||
continue
|
||||
}
|
||||
classes[t] = StyleEntryToCSS(entry)
|
||||
}
|
||||
classes[chroma.Background] += f.tabWidthStyle()
|
||||
|
@ -13,8 +13,8 @@ func TestRemappingLexer(t *testing.T) {
|
||||
{`\w+`, Name, nil},
|
||||
},
|
||||
})
|
||||
lexer = TypeRemappingLexer(lexer, TypeRemappingMap{
|
||||
{Name, Keyword}: {"if", "else"},
|
||||
lexer = TypeRemappingLexer(lexer, TypeMapping{
|
||||
{Name, Keyword, []string{"if", "else"}},
|
||||
})
|
||||
|
||||
it, err := lexer.Tokenise(nil, `if true then print else end`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user