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:
committed by
Alec Thomas
parent
d7ee3c10b0
commit
aaa96c6984
@ -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 {
|
||||
|
Reference in New Issue
Block a user