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

Add support for Go templates.

These are exposed as go-text-template and go-html-template.

Fixes #105.
This commit is contained in:
Alec Thomas
2018-03-18 21:57:34 +11:00
parent db6920e68f
commit f315512f5c
3 changed files with 65 additions and 4 deletions

View File

@ -195,7 +195,11 @@ func (l *LexerState) Iterator() *Token {
if l.Lexer.trace {
fmt.Fprintf(os.Stderr, "%s: pos=%d, text=%q\n", l.State, l.Pos, string(l.Text[l.Pos:]))
}
ruleIndex, rule, groups := matchRules(l.Text[l.Pos:], l.Rules[l.State])
selectedRule, ok := l.Rules[l.State]
if !ok {
panic("unknown state " + l.State)
}
ruleIndex, rule, groups := matchRules(l.Text[l.Pos:], selectedRule)
// No match.
if groups == nil {
l.Pos++