1
0
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:
Alec Thomas 2017-09-18 20:30:19 +10:00
parent 57c8e08560
commit 2dc153de8a

View File

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