1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-27 21:49:13 +02:00
chroma/lexers/ini.go
2017-06-07 19:47:59 +10:00

25 lines
609 B
Go

package lexers
import (
. "github.com/alecthomas/chroma" // nolint
)
var INI = Register(MustNewLexer(
&Config{
Name: "INI",
Aliases: []string{"ini", "cfg", "dosini"},
Filenames: []string{"*.ini", "*.cfg", "*.inf"},
MimeTypes: []string{"text/x-ini", "text/inf"},
},
map[string][]Rule{
"root": []Rule{
{`\s+`, Whitespace, nil},
{`;.*?$`, Comment, nil},
{`\[.*?\]$`, Keyword, nil},
{`(.*?)(\s*)(=)(\s*)(.*?)$`, ByGroups(Name, Whitespace, Operator, Whitespace, String), nil},
// standalone option, supported by some INI parsers
{`(.+?)$`, NameAttribute, nil},
},
},
))