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