ini.go

 1package i
 2
 3import (
 4	. "github.com/alecthomas/chroma" // nolint
 5	"github.com/alecthomas/chroma/lexers/internal"
 6)
 7
 8// Ini lexer.
 9var Ini = internal.Register(MustNewLexer(
10	&Config{
11		Name:      "INI",
12		Aliases:   []string{"ini", "cfg", "dosini"},
13		Filenames: []string{"*.ini", "*.cfg", "*.inf", ".gitconfig"},
14		MimeTypes: []string{"text/x-ini", "text/inf"},
15	},
16	Rules{
17		"root": {
18			{`\s+`, Text, nil},
19			{`[;#].*`, CommentSingle, nil},
20			{`\[.*?\]$`, Keyword, nil},
21			{`(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Text, Operator, Text, LiteralString), nil},
22			{`(.+?)$`, NameAttribute, nil},
23		},
24	},
25))