1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-07-07 00:46:37 +02:00

Avoid adding an HTML prefix to empty class names.

This makes the raw markup a bit cleaner when there's lots of `Text`
tokens.
This commit is contained in:
John Millikin
2018-02-24 13:15:48 -08:00
committed by Alec Thomas
parent d7ee3c10b0
commit aaa96c6984
2 changed files with 18 additions and 8 deletions

View File

@ -241,13 +241,18 @@ func (f *Formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
func (f *Formatter) class(t chroma.TokenType) string {
for t != 0 {
cls, ok := chroma.StandardTypes[t]
if ok {
return f.prefix + cls
if cls, ok := chroma.StandardTypes[t]; ok {
if cls != "" {
return f.prefix + cls
}
return ""
}
t = t.Parent()
}
return f.prefix + chroma.StandardTypes[t]
if cls := chroma.StandardTypes[t]; cls != "" {
return f.prefix + cls
}
return ""
}
func (f *Formatter) styleAttr(styles map[chroma.TokenType]string, tt chroma.TokenType) string {