Skip to content

Commit

Permalink
Detect /{/ as regex
Browse files Browse the repository at this point in the history
  • Loading branch information
JaapJoris committed Mar 16, 2023
1 parent 0ef6b75 commit 9a7a17b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion djhtml/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class DjJS(DjTXT):
r'"(?:\\.|[^"])*"', # "string"
r"'(?:\\.|[^'])*'", # 'string'
r"`(?:\\.|[^`])*`", # `string`
r"/(?:\\.|[^ /\n])(?:\\.|[^/\n])*(?:\\.|[^ /\n])/", # /string/
r"/(?=[^ ])(?:\\.|[^/\n])*/", # /[^ ]string/
r"[{[()\]}]",
r"var ",
r"let ",
Expand Down
1 change: 1 addition & 0 deletions tests/suite/js.html
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
foo = /([{/
bar = /\/{/
baz = //{//
xizzy = /{/

// The following is no longer broken \o/
/function() {/
Expand Down
1 change: 1 addition & 0 deletions tests/suite/js.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ Line([])
Line([Text(' foo = ', mode=DjJS), Text('/([{/', mode=DjJS, relative=1)], level=1)
Line([Text(' bar = ', mode=DjJS), Text('/\\/{/', mode=DjJS, relative=1)], level=1)
Line([Text(' baz = ', mode=DjJS), Text('//{//', mode=DjJS, ignore=True)], level=1)
Line([Text(' xizzy = ', mode=DjJS), Text('/{/', mode=DjJS, relative=1)], level=1)
Line([])
Line([Text(' ', mode=DjJS), Text('// The following is no longer broken \\o/', mode=DjJS, ignore=True)], level=1, ignore=True)
Line([Text(' ', mode=DjJS), Text('/function() {/', mode=DjJS)], level=1)
Expand Down

0 comments on commit 9a7a17b

Please sign in to comment.