apache.go

 1package a
 2
 3import (
 4	. "github.com/alecthomas/chroma" // nolint
 5	"github.com/alecthomas/chroma/lexers/internal"
 6)
 7
 8// Apacheconf lexer.
 9var Apacheconf = internal.Register(MustNewLexer(
10	&Config{
11		Name:            "ApacheConf",
12		Aliases:         []string{"apacheconf", "aconf", "apache"},
13		Filenames:       []string{".htaccess", "apache.conf", "apache2.conf"},
14		MimeTypes:       []string{"text/x-apacheconf"},
15		CaseInsensitive: true,
16	},
17	Rules{
18		"root": {
19			{`\s+`, Text, nil},
20			{`(#.*?)$`, Comment, nil},
21			{`(<[^\s>]+)(?:(\s+)(.*?))?(>)`, ByGroups(NameTag, Text, LiteralString, NameTag), nil},
22			{`([a-z]\w*)(\s+)`, ByGroups(NameBuiltin, Text), Push("value")},
23			{`\.+`, Text, nil},
24		},
25		"value": {
26			{`\\\n`, Text, nil},
27			{`$`, Text, Pop(1)},
28			{`\\`, Text, nil},
29			{`[^\S\n]+`, Text, nil},
30			{`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil},
31			{`\d+`, LiteralNumber, nil},
32			{`/([a-z0-9][\w./-]+)`, LiteralStringOther, nil},
33			{`(on|off|none|any|all|double|email|dns|min|minimal|os|productonly|full|emerg|alert|crit|error|warn|notice|info|debug|registry|script|inetd|standalone|user|group)\b`, Keyword, nil},
34			{`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil},
35			{`[^\s"\\]+`, Text, nil},
36		},
37	},
38))