1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-10-08 22:52:04 +02:00

Analyse() now cares about case-insensitivity (#1120)

Fixes #1118
This commit is contained in:
Thomas Sayen
2025-08-05 20:42:51 +00:00
committed by GitHub
parent 303b65df3f
commit db626fd58a

View File

@@ -150,8 +150,12 @@ func NewXMLLexer(from fs.FS, path string) (*RegexLexer, error) {
regexAnalysers := make([]regexAnalyse, 0, len(config.Analyse.Regexes)) regexAnalysers := make([]regexAnalyse, 0, len(config.Analyse.Regexes))
regexFlags := regexp2.None
if config.CaseInsensitive {
regexFlags = regexp2.IgnoreCase
}
for _, ra := range config.Analyse.Regexes { for _, ra := range config.Analyse.Regexes {
re, err := regexp2.Compile(ra.Pattern, regexp2.None) re, err := regexp2.Compile(ra.Pattern, regexFlags)
if err != nil { if err != nil {
return nil, fmt.Errorf("%s: %q is not a valid analyser regex: %w", config.Name, ra.Pattern, err) return nil, fmt.Errorf("%s: %q is not a valid analyser regex: %w", config.Name, ra.Pattern, err)
} }