mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 19:23:34 +01:00
chore(deps): bump chroma to v2 #735
Bump `alecthomas/chroma` to `v2`: https://github.com/cheat/cheat/issues/735
This commit is contained in:
33
vendor/github.com/alecthomas/chroma/v2/lexers/mysql.go
generated
vendored
Normal file
33
vendor/github.com/alecthomas/chroma/v2/lexers/mysql.go
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package lexers
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
mysqlAnalyserNameBetweenBacktickRe = regexp.MustCompile("`[a-zA-Z_]\\w*`")
|
||||
mysqlAnalyserNameBetweenBracketRe = regexp.MustCompile(`\[[a-zA-Z_]\w*\]`)
|
||||
)
|
||||
|
||||
func init() { // nolint: gochecknoinits
|
||||
Get("mysql").
|
||||
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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user