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