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>
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package e
|
|
|
|
import (
|
|
. "github.com/alecthomas/chroma" // nolint
|
|
"github.com/alecthomas/chroma/lexers/internal"
|
|
)
|
|
|
|
// Elm lexer.
|
|
var Elm = internal.Register(MustNewLexer(
|
|
&Config{
|
|
Name: "Elm",
|
|
Aliases: []string{"elm"},
|
|
Filenames: []string{"*.elm"},
|
|
MimeTypes: []string{"text/x-elm"},
|
|
},
|
|
Rules{
|
|
"root": {
|
|
{`\{-`, CommentMultiline, Push("comment")},
|
|
{`--.*`, CommentSingle, nil},
|
|
{`\s+`, Text, nil},
|
|
{`"`, LiteralString, Push("doublequote")},
|
|
{`^\s*module\s*`, KeywordNamespace, Push("imports")},
|
|
{`^\s*import\s*`, KeywordNamespace, Push("imports")},
|
|
{`\[glsl\|.*`, NameEntity, Push("shader")},
|
|
{Words(``, `\b`, `alias`, `as`, `case`, `else`, `if`, `import`, `in`, `let`, `module`, `of`, `port`, `then`, `type`, `where`), KeywordReserved, nil},
|
|
{`[A-Z]\w*`, KeywordType, nil},
|
|
{`^main `, KeywordReserved, nil},
|
|
{Words(`\(`, `\)`, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil},
|
|
{Words(``, ``, `~`, `||`, `|>`, `|`, "`", `^`, `\`, `'`, `>>`, `>=`, `>`, `==`, `=`, `<~`, `<|`, `<=`, `<<`, `<-`, `<`, `::`, `:`, `/=`, `//`, `/`, `..`, `.`, `->`, `-`, `++`, `+`, `*`, `&&`, `%`), NameFunction, nil},
|
|
Include("numbers"),
|
|
{`[a-z_][a-zA-Z_\']*`, NameVariable, nil},
|
|
{`[,()\[\]{}]`, Punctuation, nil},
|
|
},
|
|
"comment": {
|
|
{`-(?!\})`, CommentMultiline, nil},
|
|
{`\{-`, CommentMultiline, Push("comment")},
|
|
{`[^-}]`, CommentMultiline, nil},
|
|
{`-\}`, CommentMultiline, Pop(1)},
|
|
},
|
|
"doublequote": {
|
|
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
|
{`\\[nrfvb\\"]`, LiteralStringEscape, nil},
|
|
{`[^"]`, LiteralString, nil},
|
|
{`"`, LiteralString, Pop(1)},
|
|
},
|
|
"imports": {
|
|
{`\w+(\.\w+)*`, NameClass, Pop(1)},
|
|
},
|
|
"numbers": {
|
|
{`_?\d+\.(?=\d+)`, LiteralNumberFloat, nil},
|
|
{`_?\d+`, LiteralNumberInteger, nil},
|
|
},
|
|
"shader": {
|
|
{`\|(?!\])`, NameEntity, nil},
|
|
{`\|\]`, NameEntity, Pop(1)},
|
|
{`.*\n`, NameEntity, nil},
|
|
},
|
|
},
|
|
))
|