1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-31 22:05:17 +02:00
chroma/lexers/ini.go

25 lines
573 B
Go
Raw Normal View History

2017-06-02 00:17:21 +10:00
package lexers
import (
. "github.com/alecthomas/chroma" // nolint
)
// Ini lexer.
var Ini = Register(MustNewLexer(
2017-06-02 00:17:21 +10:00
&Config{
Name: "INI",
Aliases: []string{"ini", "cfg", "dosini"},
Filenames: []string{"*.ini", "*.cfg", "*.inf"},
MimeTypes: []string{"text/x-ini", "text/inf"},
},
Rules{
"root": {
{`\s+`, Text, nil},
{`[;#].*`, CommentSingle, nil},
2017-06-02 00:17:21 +10:00
{`\[.*?\]$`, Keyword, nil},
{`(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)`, ByGroups(NameAttribute, Text, Operator, Text, LiteralString), nil},
2017-06-02 00:17:21 +10:00
{`(.+?)$`, NameAttribute, nil},
},
},
))