mirror of
https://github.com/cheat/cheat.git
synced 2024-11-16 17:08:29 +01:00
55b18b4897
commit 95479c8ad744db48386a5c78e54ef8da80e9120b Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:26:32 2021 -0400 chore(version): bump version to 4.2.1 commit6956f51cae
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:24:21 2021 -0400 fix(Makefile): `vendor-update` Update the `vendor-update` build target to run `go mod vendor` after updating dependencies. commit0aca411279
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 12:23:24 2021 -0400 chore(deps): update dependencies commite847956b02
Author: Chris Lane <chris@chris-allen-lane.com> Date: Wed Apr 28 08:26:51 2021 -0400 chore(deps): build updates - Upgrade `go` to `1.16.3` - Attempt to fix build errors regarding dependencies
58 lines
1.9 KiB
Go
58 lines
1.9 KiB
Go
package y
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
var YAML = internal.Register(MustNewLazyLexer(
|
|
&Config{
|
|
Name: "YAML",
|
|
Aliases: []string{"yaml"},
|
|
Filenames: []string{"*.yaml", "*.yml"},
|
|
MimeTypes: []string{"text/x-yaml"},
|
|
},
|
|
yamlRules,
|
|
))
|
|
|
|
func yamlRules() Rules {
|
|
return Rules{
|
|
"root": {
|
|
Include("whitespace"),
|
|
{`^---`, NameNamespace, nil},
|
|
{`^\.\.\.`, NameNamespace, nil},
|
|
{`[\n?]?\s*- `, Text, nil},
|
|
{`#.*$`, Comment, nil},
|
|
{`!![^\s]+`, CommentPreproc, nil},
|
|
{`&[^\s]+`, CommentPreproc, nil},
|
|
{`\*[^\s]+`, CommentPreproc, nil},
|
|
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
|
|
Include("key"),
|
|
Include("value"),
|
|
{`[?:,\[\]]`, Punctuation, nil},
|
|
{`.`, Text, nil},
|
|
},
|
|
"value": {
|
|
{`([>|](?:[+-])?)(\n(^ {1,})(?:.*\n*(?:^\3 *).*)*)`, ByGroups(Punctuation, StringDoc, Whitespace), nil},
|
|
{Words(``, `\b`, "true", "True", "TRUE", "false", "False", "FALSE", "null",
|
|
"y", "Y", "yes", "Yes", "YES", "n", "N", "no", "No", "NO",
|
|
"on", "On", "ON", "off", "Off", "OFF"), KeywordConstant, nil},
|
|
{`"(?:\\.|[^"])*"`, StringDouble, nil},
|
|
{`'(?:\\.|[^'])*'`, StringSingle, nil},
|
|
{`\d\d\d\d-\d\d-\d\d([T ]\d\d:\d\d:\d\d(\.\d+)?(Z|\s+[-+]\d+)?)?`, LiteralDate, nil},
|
|
{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
|
|
{`([^\{\}\[\]\?,\:\!\-\*&\@].*)( )+(#.*)`, ByGroups(Literal, Whitespace, Comment), nil},
|
|
{`[^\{\}\[\]\?,\:\!\-\*&\@].*`, Literal, nil},
|
|
},
|
|
"key": {
|
|
{`"[^"\n].*": `, NameTag, nil},
|
|
{`(-)( )([^"\n{]*)(:)( )`, ByGroups(Punctuation, Whitespace, NameTag, Punctuation, Whitespace), nil},
|
|
{`([^"\n{]*)(:)( )`, ByGroups(NameTag, Punctuation, Whitespace), nil},
|
|
{`([^"\n{]*)(:)(\n)`, ByGroups(NameTag, Punctuation, Whitespace), nil},
|
|
},
|
|
"whitespace": {
|
|
{`\s+`, Whitespace, nil},
|
|
{`\n+`, Whitespace, nil},
|
|
},
|
|
}
|
|
}
|