mirror of
https://github.com/alecthomas/chroma.git
synced 2025-11-23 22:24:39 +02:00
Use a callback to emit tokens.
This is a) faster and b) supports streaming output.
This commit is contained in:
4
types.go
4
types.go
@@ -176,6 +176,6 @@ func (t TokenType) InSubCategory(other TokenType) bool {
|
||||
return t/100 == other/100
|
||||
}
|
||||
|
||||
func (t TokenType) Emit(groups []string) []Token {
|
||||
return []Token{Token{Type: t, Value: groups[0]}}
|
||||
func (t TokenType) Emit(groups []string, out func(Token)) {
|
||||
out(Token{Type: t, Value: groups[0]})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user