systemd.go

 1package s
 2
 3import (
 4	. "github.com/alecthomas/chroma" // nolint
 5	"github.com/alecthomas/chroma/lexers/internal"
 6)
 7
 8var SYSTEMD = internal.Register(MustNewLexer(
 9	&Config{
10		Name:      "SYSTEMD",
11		Aliases:   []string{"systemd"},
12		Filenames: []string{"*.service"},
13		MimeTypes: []string{"text/plain"},
14	},
15	Rules{
16		"root": {
17			{`\s+`, Text, nil},
18			{`[;#].*`, Comment, nil},
19			{`\[.*?\]$`, Keyword, nil},
20			{`(.*?)(=)(.*)(\\\n)`, ByGroups(NameAttribute, Operator, LiteralString, Text), Push("continuation")},
21			{`(.*?)(=)(.*)`, ByGroups(NameAttribute, Operator, LiteralString), nil},
22		},
23		"continuation": {
24			{`(.*?)(\\\n)`, ByGroups(LiteralString, Text), nil},
25			{`(.*)`, LiteralString, Pop(1)},
26		},
27	},
28))