mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-09 05:12:56 +02:00
Update Dependencies (#390)
Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: Norwin <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/390 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Norwin <noerw@noreply.gitea.io> Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
44
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
44
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
@ -11,6 +11,19 @@ import (
|
||||
"github.com/alecthomas/chroma"
|
||||
)
|
||||
|
||||
var (
|
||||
ignoredSuffixes = [...]string{
|
||||
// Editor backups
|
||||
"~", ".bak", ".old", ".orig",
|
||||
// Debian and derivatives apt/dpkg backups
|
||||
".dpkg-dist", ".dpkg-old",
|
||||
// Red Hat and derivatives rpm backups
|
||||
".rpmnew", ".rpmorig", ".rpmsave",
|
||||
// Build system input/template files
|
||||
".in",
|
||||
}
|
||||
)
|
||||
|
||||
// Registry of Lexers.
|
||||
var Registry = struct {
|
||||
Lexers chroma.Lexers
|
||||
@ -93,6 +106,13 @@ func Match(filename string) chroma.Lexer {
|
||||
for _, glob := range config.Filenames {
|
||||
if fnmatch.Match(glob, filename, 0) {
|
||||
matched = append(matched, lexer)
|
||||
} else {
|
||||
for _, suf := range &ignoredSuffixes {
|
||||
if fnmatch.Match(glob+suf, filename, 0) {
|
||||
matched = append(matched, lexer)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +127,13 @@ func Match(filename string) chroma.Lexer {
|
||||
for _, glob := range config.AliasFilenames {
|
||||
if fnmatch.Match(glob, filename, 0) {
|
||||
matched = append(matched, lexer)
|
||||
} else {
|
||||
for _, suf := range &ignoredSuffixes {
|
||||
if fnmatch.Match(glob+suf, filename, 0) {
|
||||
matched = append(matched, lexer)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,16 +173,19 @@ func Register(lexer chroma.Lexer) chroma.Lexer {
|
||||
return lexer
|
||||
}
|
||||
|
||||
// Used for the fallback lexer as well as the explicit plaintext lexer
|
||||
var PlaintextRules = chroma.Rules{
|
||||
"root": []chroma.Rule{
|
||||
{`.+`, chroma.Text, nil},
|
||||
{`\n`, chroma.Text, nil},
|
||||
},
|
||||
// PlaintextRules is used for the fallback lexer as well as the explicit
|
||||
// plaintext lexer.
|
||||
func PlaintextRules() chroma.Rules {
|
||||
return chroma.Rules{
|
||||
"root": []chroma.Rule{
|
||||
{`.+`, chroma.Text, nil},
|
||||
{`\n`, chroma.Text, nil},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback lexer if no other is found.
|
||||
var Fallback chroma.Lexer = chroma.MustNewLexer(&chroma.Config{
|
||||
var Fallback chroma.Lexer = chroma.MustNewLazyLexer(&chroma.Config{
|
||||
Name: "fallback",
|
||||
Filenames: []string{"*"},
|
||||
}, PlaintextRules)
|
||||
|
Reference in New Issue
Block a user