forked from forgejo/forgejo
Update Vendor (#16325)
* Add Dependencie Update Script * update gitea.com/lunny/levelqueue * update github.com/PuerkitoBio/goquery * update github.com/alecthomas/chroma * update github.com/blevesearch/bleve/v2 * update github.com/caddyserver/certmagic * update github.com/go-enry/go-enry/v2 * update github.com/go-redis/redis/v8 * update github.com/hashicorp/golang-lru * update github.com/klauspost/compress * update github.com/markbates/goth * update github.com/mholt/archiver/v3 * update github.com/microcosm-cc/bluemonday * update github.com/minio/minio-go/v7 * update github.com/olivere/elastic/v7 * update github.com/xanzy/go-gitlab * update github.com/yuin/goldmark
This commit is contained in:
parent
65ae46bc20
commit
fae07cbc8f
319 changed files with 33568 additions and 21050 deletions
2
vendor/github.com/alecthomas/chroma/lexers/m/markdown.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/m/markdown.go
generated
vendored
|
@ -40,7 +40,7 @@ func markdownRules() Rules {
|
|||
},
|
||||
"inline": {
|
||||
{`\\.`, Text, nil},
|
||||
{`(\s)([*_][^*_]+[*_])(\W|\n)`, ByGroups(Text, GenericEmph, Text), nil},
|
||||
{`(\s)(\*|_)((?:(?!\2).)*)(\2)((?=\W|\n))`, ByGroups(Text, GenericEmph, GenericEmph, GenericEmph, Text), nil},
|
||||
{`(\s)((\*\*|__).*?)\3((?=\W|\n))`, ByGroups(Text, GenericStrong, GenericStrong, Text), nil},
|
||||
{`(\s)(~~[^~]+~~)((?=\W|\n))`, ByGroups(Text, GenericDeleted, Text), nil},
|
||||
{"`[^`]+`", LiteralStringBacktick, nil},
|
||||
|
|
180
vendor/github.com/alecthomas/chroma/lexers/m/mcfunction.go
generated
vendored
180
vendor/github.com/alecthomas/chroma/lexers/m/mcfunction.go
generated
vendored
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
// mcfunction lexer.
|
||||
var MCFunction = internal.Register(MustNewLexer(
|
||||
var MCFunction = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "mcfunction",
|
||||
Aliases: []string{"mcfunction"},
|
||||
|
@ -15,93 +15,95 @@ var MCFunction = internal.Register(MustNewLexer(
|
|||
NotMultiline: true,
|
||||
DotAll: true,
|
||||
},
|
||||
Rules{
|
||||
"simplevalue": {
|
||||
{`(true|false)`, KeywordConstant, nil},
|
||||
{`[01]b`, LiteralNumber, nil},
|
||||
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
|
||||
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
|
||||
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'[^']+'`, LiteralStringSingle, nil},
|
||||
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
|
||||
},
|
||||
"nbtobjectattribute": {
|
||||
Include("nbtvalue"),
|
||||
{`:`, Punctuation, nil},
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`\}`, Punctuation, Pop(2)},
|
||||
},
|
||||
"nbtobjectvalue": {
|
||||
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"nbtarrayvalue": {
|
||||
Include("nbtvalue"),
|
||||
{`,`, Punctuation, nil},
|
||||
{`\]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"nbtvalue": {
|
||||
Include("simplevalue"),
|
||||
{`\{`, Punctuation, Push("nbtobjectvalue")},
|
||||
{`\[`, Punctuation, Push("nbtarrayvalue")},
|
||||
},
|
||||
"argumentvalue": {
|
||||
Include("simplevalue"),
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`[}\]]`, Punctuation, Pop(2)},
|
||||
},
|
||||
"argumentlist": {
|
||||
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
|
||||
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
|
||||
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
|
||||
Include("simplevalue"),
|
||||
{`,`, Punctuation, nil},
|
||||
{`[}\]]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
{`#.*?\n`, CommentSingle, nil},
|
||||
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
|
||||
`ban`, `ban-ip`, `banlist`, `bossbar`,
|
||||
`camerashake`, `classroommode`, `clear`,
|
||||
`clearspawnpoint`, `clone`, `code`, `collect`,
|
||||
`createagent`, `data`, `datapack`, `debug`,
|
||||
`defaultgamemode`, `deop`, `destroy`, `detect`,
|
||||
`detectredstone`, `difficulty`, `dropall`,
|
||||
`effect`, `enchant`, `event`, `execute`,
|
||||
`experience`, `fill`, `flog`, `forceload`,
|
||||
`function`, `gamemode`, `gamerule`,
|
||||
`geteduclientinfo`, `give`, `help`, `item`,
|
||||
`immutableworld`, `kick`, `kill`, `list`,
|
||||
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
|
||||
`mobevent`, `move`, `msg`, `music`, `op`,
|
||||
`pardon`, `particle`, `playanimation`,
|
||||
`playsound`, `position`, `publish`,
|
||||
`raytracefog`, `recipe`, `reload`, `remove`,
|
||||
`replaceitem`, `ride`, `save`, `save-all`,
|
||||
`save-off`, `save-on`, `say`, `schedule`,
|
||||
`scoreboard`, `seed`, `setblock`,
|
||||
`setidletimeout`, `setmaxplayers`,
|
||||
`setworldspawn`, `spawnpoint`, `spectate`,
|
||||
`spreadplayers`, `stop`, `stopsound`,
|
||||
`structure`, `summon`, `tag`, `team`, `teammsg`,
|
||||
`teleport`, `tell`, `tellraw`, `testfor`,
|
||||
`testforblock`, `testforblocks`, `tickingarea`,
|
||||
`time`, `title`, `toggledownfall`, `tp`,
|
||||
`tpagent`, `transfer`, `transferserver`,
|
||||
`trigger`, `turn`, `w`, `weather`, `whitelist`,
|
||||
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
|
||||
), KeywordReserved, nil},
|
||||
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
|
||||
KeywordConstant, nil},
|
||||
{`\[`, Punctuation, Push("argumentlist")},
|
||||
{`{`, Punctuation, Push("nbtobjectvalue")},
|
||||
{`~`, NameBuiltin, nil},
|
||||
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
|
||||
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
|
||||
{`([<>=]|<=|>=)`, Punctuation, nil},
|
||||
Include("simplevalue"),
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
},
|
||||
func() Rules {
|
||||
return Rules{
|
||||
"simplevalue": {
|
||||
{`(true|false)`, KeywordConstant, nil},
|
||||
{`[01]b`, LiteralNumber, nil},
|
||||
{`-?(0|[1-9]\d*)(\.\d+[eE](\+|-)?\d+|[eE](\+|-)?\d+|\.\d+)`, LiteralNumberFloat, nil},
|
||||
{`(-?\d+)(\.\.)(-?\d+)`, ByGroups(LiteralNumberInteger, Punctuation, LiteralNumberInteger), nil},
|
||||
{`-?(0|[1-9]\d*)`, LiteralNumberInteger, nil},
|
||||
{`"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
|
||||
{`'[^']+'`, LiteralStringSingle, nil},
|
||||
{`([!#]?)(\w+)`, ByGroups(Punctuation, Text), nil},
|
||||
},
|
||||
"nbtobjectattribute": {
|
||||
Include("nbtvalue"),
|
||||
{`:`, Punctuation, nil},
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`\}`, Punctuation, Pop(2)},
|
||||
},
|
||||
"nbtobjectvalue": {
|
||||
{`("(\\\\|\\"|[^"])*"|[a-zA-Z0-9_]+)`, NameTag, Push("nbtobjectattribute")},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"nbtarrayvalue": {
|
||||
Include("nbtvalue"),
|
||||
{`,`, Punctuation, nil},
|
||||
{`\]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"nbtvalue": {
|
||||
Include("simplevalue"),
|
||||
{`\{`, Punctuation, Push("nbtobjectvalue")},
|
||||
{`\[`, Punctuation, Push("nbtarrayvalue")},
|
||||
},
|
||||
"argumentvalue": {
|
||||
Include("simplevalue"),
|
||||
{`,`, Punctuation, Pop(1)},
|
||||
{`[}\]]`, Punctuation, Pop(2)},
|
||||
},
|
||||
"argumentlist": {
|
||||
{`(nbt)(={)`, ByGroups(NameAttribute, Punctuation), Push("nbtobjectvalue")},
|
||||
{`([A-Za-z0-9/_!]+)(={)`, ByGroups(NameAttribute, Punctuation), Push("argumentlist")},
|
||||
{`([A-Za-z0-9/_!]+)(=)`, ByGroups(NameAttribute, Punctuation), Push("argumentvalue")},
|
||||
Include("simplevalue"),
|
||||
{`,`, Punctuation, nil},
|
||||
{`[}\]]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"root": {
|
||||
{`#.*?\n`, CommentSingle, nil},
|
||||
{Words(`/?`, `\b`, `ability`, `attributes`, `advancement`,
|
||||
`ban`, `ban-ip`, `banlist`, `bossbar`,
|
||||
`camerashake`, `classroommode`, `clear`,
|
||||
`clearspawnpoint`, `clone`, `code`, `collect`,
|
||||
`createagent`, `data`, `datapack`, `debug`,
|
||||
`defaultgamemode`, `deop`, `destroy`, `detect`,
|
||||
`detectredstone`, `difficulty`, `dropall`,
|
||||
`effect`, `enchant`, `event`, `execute`,
|
||||
`experience`, `fill`, `flog`, `forceload`,
|
||||
`function`, `gamemode`, `gamerule`,
|
||||
`geteduclientinfo`, `give`, `help`, `item`,
|
||||
`immutableworld`, `kick`, `kill`, `list`,
|
||||
`locate`, `locatebiome`, `loot`, `me`, `mixer`,
|
||||
`mobevent`, `move`, `msg`, `music`, `op`,
|
||||
`pardon`, `particle`, `playanimation`,
|
||||
`playsound`, `position`, `publish`,
|
||||
`raytracefog`, `recipe`, `reload`, `remove`,
|
||||
`replaceitem`, `ride`, `save`, `save-all`,
|
||||
`save-off`, `save-on`, `say`, `schedule`,
|
||||
`scoreboard`, `seed`, `setblock`,
|
||||
`setidletimeout`, `setmaxplayers`,
|
||||
`setworldspawn`, `spawnpoint`, `spectate`,
|
||||
`spreadplayers`, `stop`, `stopsound`,
|
||||
`structure`, `summon`, `tag`, `team`, `teammsg`,
|
||||
`teleport`, `tell`, `tellraw`, `testfor`,
|
||||
`testforblock`, `testforblocks`, `tickingarea`,
|
||||
`time`, `title`, `toggledownfall`, `tp`,
|
||||
`tpagent`, `transfer`, `transferserver`,
|
||||
`trigger`, `turn`, `w`, `weather`, `whitelist`,
|
||||
`worldborder`, `worldbuilder`, `wsserver`, `xp`,
|
||||
), KeywordReserved, nil},
|
||||
{Words(``, ``, `@p`, `@r`, `@a`, `@e`, `@s`, `@c`, `@v`),
|
||||
KeywordConstant, nil},
|
||||
{`\[`, Punctuation, Push("argumentlist")},
|
||||
{`{`, Punctuation, Push("nbtobjectvalue")},
|
||||
{`~`, NameBuiltin, nil},
|
||||
{`([a-zA-Z_]+:)?[a-zA-Z_]+\b`, Text, nil},
|
||||
{`([a-z]+)(\.)([0-9]+)\b`, ByGroups(Text, Punctuation, LiteralNumber), nil},
|
||||
{`([<>=]|<=|>=)`, Punctuation, nil},
|
||||
Include("simplevalue"),
|
||||
{`\s+`, TextWhitespace, nil},
|
||||
},
|
||||
}
|
||||
},
|
||||
))
|
||||
|
|
101
vendor/github.com/alecthomas/chroma/lexers/m/metal.go
generated
vendored
Normal file
101
vendor/github.com/alecthomas/chroma/lexers/m/metal.go
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
package m
|
||||
|
||||
import (
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
// Metal lexer.
|
||||
var Metal = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
Name: "Metal",
|
||||
Aliases: []string{"metal"},
|
||||
Filenames: []string{"*.metal"},
|
||||
MimeTypes: []string{"text/x-metal"},
|
||||
EnsureNL: true,
|
||||
},
|
||||
metalRules,
|
||||
))
|
||||
|
||||
func metalRules() Rules {
|
||||
return Rules{
|
||||
"statements": {
|
||||
{Words(``, `\b`, `namespace`, `operator`, `template`, `this`, `using`, `constexpr`), Keyword, nil},
|
||||
{`(enum)\b(\s+)(class)\b(\s*)`, ByGroups(Keyword, Text, Keyword, Text), Push("classname")},
|
||||
{`(class|struct|enum|union)\b(\s*)`, ByGroups(Keyword, Text), Push("classname")},
|
||||
{`\[\[.+\]\]`, NameAttribute, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||
{`0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*`, LiteralNumberHex, nil},
|
||||
{`0('?[0-7]+)+[LlUu]*`, LiteralNumberOct, nil},
|
||||
{`0[Bb][01]('?[01]+)*[LlUu]*`, LiteralNumberBin, nil},
|
||||
{`[0-9]('?[0-9]+)*[LlUu]*`, LiteralNumberInteger, nil},
|
||||
{`\*/`, Error, nil},
|
||||
{`[~!%^&*+=|?:<>/-]`, Operator, nil},
|
||||
{`[()\[\],.]`, Punctuation, nil},
|
||||
{Words(``, `\b`, `break`, `case`, `const`, `continue`, `do`, `else`, `enum`, `extern`, `for`, `if`, `return`, `sizeof`, `static`, `struct`, `switch`, `typedef`, `union`, `while`), Keyword, nil},
|
||||
{`(bool|float|half|long|ptrdiff_t|size_t|unsigned|u?char|u?int((8|16|32|64)_t)?|u?short)\b`, KeywordType, nil},
|
||||
{`(bool|float|half|u?(char|int|long|short))(2|3|4)\b`, KeywordType, nil},
|
||||
{`packed_(float|half|long|u?(char|int|short))(2|3|4)\b`, KeywordType, nil},
|
||||
{`(float|half)(2|3|4)x(2|3|4)\b`, KeywordType, nil},
|
||||
{`atomic_u?int\b`, KeywordType, nil},
|
||||
{`(rg?(8|16)(u|s)norm|rgba(8|16)(u|s)norm|srgba8unorm|rgb10a2|rg11b10f|rgb9e5)\b`, KeywordType, nil},
|
||||
{`(array|depth(2d|cube)(_array)?|depth2d_ms(_array)?|sampler|texture_buffer|texture(1|2)d(_array)?|texture2d_ms(_array)?|texture3d|texturecube(_array)?|uniform|visible_function_table)\b`, KeywordType, nil},
|
||||
{`(true|false|NULL)\b`, NameBuiltin, nil},
|
||||
{Words(``, `\b`, `device`, `constant`, `ray_data`, `thread`, `threadgroup`, `threadgroup_imageblock`), Keyword, nil},
|
||||
{`([a-zA-Z_]\w*)(\s*)(:)(?!:)`, ByGroups(NameLabel, Text, Punctuation), nil},
|
||||
{`[a-zA-Z_]\w*`, Name, nil},
|
||||
},
|
||||
"root": {
|
||||
Include("whitespace"),
|
||||
{`(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;{]*)(\{)`, ByGroups(Keyword, UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), Push("function")},
|
||||
{`(fragment|kernel|vertex)?((?:[\w*\s])+?(?:\s|[*]))([a-zA-Z_]\w*)(\s*\([^;]*?\))([^;]*)(;)`, ByGroups(Keyword, UsingSelf("root"), NameFunction, UsingSelf("root"), UsingSelf("root"), Punctuation), nil},
|
||||
Default(Push("statement")),
|
||||
},
|
||||
"classname": {
|
||||
{`(\[\[.+\]\])(\s*)`, ByGroups(NameAttribute, Text), nil},
|
||||
{`[a-zA-Z_]\w*`, NameClass, Pop(1)},
|
||||
{`\s*(?=[>{])`, Text, Pop(1)},
|
||||
},
|
||||
"whitespace": {
|
||||
{`^#if\s+0`, CommentPreproc, Push("if0")},
|
||||
{`^#`, CommentPreproc, Push("macro")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#if\s+0)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("if0")},
|
||||
{`^(\s*(?:/[*].*?[*]/\s*)?)(#)`, ByGroups(UsingSelf("root"), CommentPreproc), Push("macro")},
|
||||
{`\n`, Text, nil},
|
||||
{`\s+`, Text, nil},
|
||||
{`\\\n`, Text, nil},
|
||||
{`//(\n|[\w\W]*?[^\\]\n)`, CommentSingle, nil},
|
||||
{`/(\\\n)?[*][\w\W]*?[*](\\\n)?/`, CommentMultiline, nil},
|
||||
{`/(\\\n)?[*][\w\W]*`, CommentMultiline, nil},
|
||||
},
|
||||
"statement": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`[{]`, Punctuation, Push("root")},
|
||||
{`[;}]`, Punctuation, Pop(1)},
|
||||
},
|
||||
"function": {
|
||||
Include("whitespace"),
|
||||
Include("statements"),
|
||||
{`;`, Punctuation, nil},
|
||||
{`\{`, Punctuation, Push()},
|
||||
{`\}`, Punctuation, Pop(1)},
|
||||
},
|
||||
"macro": {
|
||||
{`(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)`, ByGroups(CommentPreproc, Text, CommentPreprocFile), nil},
|
||||
{`[^/\n]+`, CommentPreproc, nil},
|
||||
{`/[*](.|\n)*?[*]/`, CommentMultiline, nil},
|
||||
{`//.*?\n`, CommentSingle, Pop(1)},
|
||||
{`/`, CommentPreproc, nil},
|
||||
{`(?<=\\)\n`, CommentPreproc, nil},
|
||||
{`\n`, CommentPreproc, Pop(1)},
|
||||
},
|
||||
"if0": {
|
||||
{`^\s*#if.*?(?<!\\)\n`, CommentPreproc, Push()},
|
||||
{`^\s*#el(?:se|if).*\n`, CommentPreproc, Pop(1)},
|
||||
{`^\s*#endif.*?(?<!\\)\n`, CommentPreproc, Pop(1)},
|
||||
{`.*?\n`, Comment, nil},
|
||||
},
|
||||
}
|
||||
}
|
10
vendor/github.com/alecthomas/chroma/lexers/m/myghty.go
generated
vendored
10
vendor/github.com/alecthomas/chroma/lexers/m/myghty.go
generated
vendored
|
@ -22,13 +22,13 @@ func myghtyRules() Rules {
|
|||
"root": {
|
||||
{`\s+`, Text, nil},
|
||||
{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil},
|
||||
{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python), NameTag), nil},
|
||||
{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python), NameTag), nil},
|
||||
{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python), NameTag), nil},
|
||||
{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python2), NameTag), nil},
|
||||
{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
|
||||
{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
|
||||
{`</&>`, NameTag, nil},
|
||||
{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python), NameTag), nil},
|
||||
{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python2), NameTag), nil},
|
||||
{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil},
|
||||
{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python), Other), nil},
|
||||
{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python2), Other), nil},
|
||||
{`(?sx)
|
||||
(.+?) # anything, followed by:
|
||||
(?:
|
||||
|
|
27
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
27
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
|
@ -1,10 +1,17 @@
|
|||
package m
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
"github.com/alecthomas/chroma/lexers/internal"
|
||||
)
|
||||
|
||||
var (
|
||||
mysqlAnalyserNameBetweenBacktickRe = regexp.MustCompile("`[a-zA-Z_]\\w*`")
|
||||
mysqlAnalyserNameBetweenBracketRe = regexp.MustCompile(`\[[a-zA-Z_]\w*\]`)
|
||||
)
|
||||
|
||||
// MySQL lexer.
|
||||
var MySQL = internal.Register(MustNewLazyLexer(
|
||||
&Config{
|
||||
|
@ -16,7 +23,25 @@ var MySQL = internal.Register(MustNewLazyLexer(
|
|||
CaseInsensitive: true,
|
||||
},
|
||||
mySQLRules,
|
||||
))
|
||||
).SetAnalyser(func(text string) float32 {
|
||||
nameBetweenBacktickCount := len(mysqlAnalyserNameBetweenBacktickRe.FindAllString(text, -1))
|
||||
nameBetweenBracketCount := len(mysqlAnalyserNameBetweenBracketRe.FindAllString(text, -1))
|
||||
|
||||
var result float32
|
||||
|
||||
// Same logic as above in the TSQL analysis.
|
||||
dialectNameCount := nameBetweenBacktickCount + nameBetweenBracketCount
|
||||
if dialectNameCount >= 1 && nameBetweenBacktickCount >= (2*nameBetweenBracketCount) {
|
||||
// Found at least twice as many `name` as [name].
|
||||
result += 0.5
|
||||
} else if nameBetweenBacktickCount > nameBetweenBracketCount {
|
||||
result += 0.2
|
||||
} else if nameBetweenBacktickCount > 0 {
|
||||
result += 0.1
|
||||
}
|
||||
|
||||
return result
|
||||
}))
|
||||
|
||||
func mySQLRules() Rules {
|
||||
return Rules{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue