1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-02-15 13:33:12 +02:00

feat(regexlexer): compile in RE2 compatibility mode

To better match vanilla Go regexps and support some additional
constructs that might be present in Pygments rules.

https://github.com/dlclark/regexp2#re2-compatibility-mode
This commit is contained in:
Ville Skyttä 2021-05-16 22:21:14 +03:00 committed by Alec Thomas
parent 4d45300557
commit b5d03c0079

View File

@ -404,7 +404,7 @@ func (r *RegexLexer) maybeCompile() (err error) {
pattern = "(?" + rule.flags + ")" + pattern pattern = "(?" + rule.flags + ")" + pattern
} }
pattern = `\G` + pattern pattern = `\G` + pattern
rule.Regexp, err = regexp2.Compile(pattern, 0) rule.Regexp, err = regexp2.Compile(pattern, regexp2.RE2)
if err != nil { if err != nil {
return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err) return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err)
} }