mirror of
https://github.com/alecthomas/chroma.git
synced 2025-01-28 03:29:41 +02:00
Add analyser for bash.
This commit is contained in:
parent
57c8e08560
commit
2dc153de8a
@ -1,9 +1,13 @@
|
||||
package lexers
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
. "github.com/alecthomas/chroma" // nolint
|
||||
)
|
||||
|
||||
var bashAnalyserRe = regexp.MustCompile(`(?m)^#!.*/bin/(?:bash|zsh|sh|ksh)`)
|
||||
|
||||
// Bash lexer.
|
||||
var Bash = Register(MustNewLexer(
|
||||
&Config{
|
||||
@ -82,4 +86,9 @@ var Bash = Register(MustNewLexer(
|
||||
Include("root"),
|
||||
},
|
||||
},
|
||||
))
|
||||
).SetAnalyser(func(text string) float32 {
|
||||
if bashAnalyserRe.FindString(text) != "" {
|
||||
return 1.0
|
||||
}
|
||||
return 0.0
|
||||
}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user