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:
Norwin
2021-08-30 23:18:50 +08:00
committed by Andrew Thornton
parent 4b9907fb54
commit d6df0a53b5
665 changed files with 29466 additions and 24547 deletions

View File

@ -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)