mirror of
https://gitea.com/gitea/tea.git
synced 2024-12-04 14:46:40 -05:00
89e93d90b3
Merge branch 'master' into use-glamour select Glamour Theme based on BackgroundColor Merge branch 'master' into use-glamour Merge branch 'master' into use-glamour update termev update go.mod label color colorate use glamour for issue content Vendor: Add glamour Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/181 Reviewed-by: techknowlogick <techknowlogick@gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
92 lines
3.2 KiB
Go
92 lines
3.2 KiB
Go
package d
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Dart lexer.
|
|
var Dart = internal.Register(MustNewLexer(
|
|
&Config{
|
|
Name: "Dart",
|
|
Aliases: []string{"dart"},
|
|
Filenames: []string{"*.dart"},
|
|
MimeTypes: []string{"text/x-dart"},
|
|
DotAll: true,
|
|
},
|
|
Rules{
|
|
"root": {
|
|
Include("string_literal"),
|
|
{`#!(.*?)$`, CommentPreproc, nil},
|
|
{`\b(import|export)\b`, Keyword, Push("import_decl")},
|
|
{`\b(library|source|part of|part)\b`, Keyword, nil},
|
|
{`[^\S\n]+`, Text, nil},
|
|
{`//.*?\n`, CommentSingle, nil},
|
|
{`/\*.*?\*/`, CommentMultiline, nil},
|
|
{`\b(class)\b(\s+)`, ByGroups(KeywordDeclaration, Text), Push("class")},
|
|
{`\b(assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b`, Keyword, nil},
|
|
{`\b(abstract|async|await|const|extends|factory|final|get|implements|native|operator|set|static|sync|typedef|var|with|yield)\b`, KeywordDeclaration, nil},
|
|
{`\b(bool|double|dynamic|int|num|Object|String|void)\b`, KeywordType, nil},
|
|
{`\b(false|null|true)\b`, KeywordConstant, nil},
|
|
{`[~!%^&*+=|?:<>/-]|as\b`, Operator, nil},
|
|
{`[a-zA-Z_$]\w*:`, NameLabel, nil},
|
|
{`[a-zA-Z_$]\w*`, Name, nil},
|
|
{`[(){}\[\],.;]`, Punctuation, nil},
|
|
{`0[xX][0-9a-fA-F]+`, LiteralNumberHex, nil},
|
|
{`\d+(\.\d*)?([eE][+-]?\d+)?`, LiteralNumber, nil},
|
|
{`\.\d+([eE][+-]?\d+)?`, LiteralNumber, nil},
|
|
{`\n`, Text, nil},
|
|
},
|
|
"class": {
|
|
{`[a-zA-Z_$]\w*`, NameClass, Pop(1)},
|
|
},
|
|
"import_decl": {
|
|
Include("string_literal"),
|
|
{`\s+`, Text, nil},
|
|
{`\b(as|show|hide)\b`, Keyword, nil},
|
|
{`[a-zA-Z_$]\w*`, Name, nil},
|
|
{`\,`, Punctuation, nil},
|
|
{`\;`, Punctuation, Pop(1)},
|
|
},
|
|
"string_literal": {
|
|
{`r"""([\w\W]*?)"""`, LiteralStringDouble, nil},
|
|
{`r'''([\w\W]*?)'''`, LiteralStringSingle, nil},
|
|
{`r"(.*?)"`, LiteralStringDouble, nil},
|
|
{`r'(.*?)'`, LiteralStringSingle, nil},
|
|
{`"""`, LiteralStringDouble, Push("string_double_multiline")},
|
|
{`'''`, LiteralStringSingle, Push("string_single_multiline")},
|
|
{`"`, LiteralStringDouble, Push("string_double")},
|
|
{`'`, LiteralStringSingle, Push("string_single")},
|
|
},
|
|
"string_common": {
|
|
{`\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\{[0-9A-Fa-f]*\}|[a-z'\"$\\])`, LiteralStringEscape, nil},
|
|
{`(\$)([a-zA-Z_]\w*)`, ByGroups(LiteralStringInterpol, Name), nil},
|
|
{`(\$\{)(.*?)(\})`, ByGroups(LiteralStringInterpol, UsingSelf("root"), LiteralStringInterpol), nil},
|
|
},
|
|
"string_double": {
|
|
{`"`, LiteralStringDouble, Pop(1)},
|
|
{`[^"$\\\n]+`, LiteralStringDouble, nil},
|
|
Include("string_common"),
|
|
{`\$+`, LiteralStringDouble, nil},
|
|
},
|
|
"string_double_multiline": {
|
|
{`"""`, LiteralStringDouble, Pop(1)},
|
|
{`[^"$\\]+`, LiteralStringDouble, nil},
|
|
Include("string_common"),
|
|
{`(\$|\")+`, LiteralStringDouble, nil},
|
|
},
|
|
"string_single": {
|
|
{`'`, LiteralStringSingle, Pop(1)},
|
|
{`[^'$\\\n]+`, LiteralStringSingle, nil},
|
|
Include("string_common"),
|
|
{`\$+`, LiteralStringSingle, nil},
|
|
},
|
|
"string_single_multiline": {
|
|
{`'''`, LiteralStringSingle, Pop(1)},
|
|
{`[^\'$\\]+`, LiteralStringSingle, nil},
|
|
Include("string_common"),
|
|
{`(\$|\')+`, LiteralStringSingle, nil},
|
|
},
|
|
},
|
|
))
|