1package y
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8var YAML = internal.Register(MustNewLexer(
9 &Config{
10 Name: "YAML",
11 Aliases: []string{"yaml"},
12 Filenames: []string{"*.yaml", "*.yml"},
13 MimeTypes: []string{"text/x-yaml"},
14 },
15 Rules{
16 "root": {
17 Include("whitespace"),
18 {`#.*`, Comment, nil},
19 {`!![^\s]+`, CommentPreproc, nil},
20 {`&[^\s]+`, CommentPreproc, nil},
21 {`\*[^\s]+`, CommentPreproc, nil},
22 {`^%include\s+[^\n\r]+`, CommentPreproc, nil},
23 {`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
24 Include("value"),
25 {`[?:,\[\]]`, Punctuation, nil},
26 {`.`, Text, nil},
27 },
28 "value": {
29 {Words(``, `\b`, "true", "false", "null"), KeywordConstant, nil},
30 {`"(?:\\.|[^"])*"`, StringDouble, nil},
31 {`'(?:\\.|[^'])*'`, StringSingle, nil},
32 {`\d\d\d\d-\d\d-\d\d([T ]\d\d:\d\d:\d\d(\.\d+)?(Z|\s+[-+]\d+)?)?`, LiteralDate, nil},
33 {`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
34 {`\b[\w]+\b`, Text, nil},
35 },
36 "whitespace": {
37 {`\s+`, Whitespace, nil},
38 },
39 },
40))