Skip to content

Commit

Permalink
feat(regexlexer): compile in RE2 compatibility mode
Browse files Browse the repository at this point in the history
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
  • Loading branch information
scop authored and alecthomas committed May 17, 2021
1 parent 4d45300 commit b5d03c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (r *RegexLexer) maybeCompile() (err error) {
pattern = "(?" + rule.flags + ")" + pattern
}
pattern = `\G` + pattern
rule.Regexp, err = regexp2.Compile(pattern, 0)
rule.Regexp, err = regexp2.Compile(pattern, regexp2.RE2)
if err != nil {
return fmt.Errorf("failed to compile rule %s.%d: %s", state, i, err)
}
Expand Down

0 comments on commit b5d03c0

Please sign in to comment.