From 0ef6b75486b0c73305795bac1f4c745cb448ac30 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 14 Mar 2023 21:25:39 +0100 Subject: [PATCH 1/2] Fix javascript regular expression literals --- djhtml/modes.py | 8 ++++---- setup.cfg | 2 +- tests/suite/js.html | 5 ++--- tests/suite/js.tokens | 9 ++++----- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/djhtml/modes.py b/djhtml/modes.py index 02a7744..72ae4a0 100644 --- a/djhtml/modes.py +++ b/djhtml/modes.py @@ -385,10 +385,10 @@ class DjJS(DjTXT): r"//.*", r"/\*", r"[$\w-]+:", - r'"(?:\\.|[^\\"])*"', # "string" - r"'(?:\\.|[^\\'])*'", # 'string' - r"`(?:\\.|[^\\`])*`", # `string` - r"/(?:\\.|[^\\/ \n])*/", # /string/ (but without spaces) + r'"(?:\\.|[^"])*"', # "string" + r"'(?:\\.|[^'])*'", # 'string' + r"`(?:\\.|[^`])*`", # `string` + r"/(?:\\.|[^ /\n])(?:\\.|[^/\n])*(?:\\.|[^ /\n])/", # /string/ r"[{[()\]}]", r"var ", r"let ", diff --git a/setup.cfg b/setup.cfg index 2f1049d..73a41d8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = djhtml -version = 3.0.5 +version = 3.0.6 description = Django/Jinja template indenter long_description = file: README.md long_description_content_type = text/markdown diff --git a/tests/suite/js.html b/tests/suite/js.html index 74c3650..60cd36e 100644 --- a/tests/suite/js.html +++ b/tests/suite/js.html @@ -456,8 +456,7 @@ bar = /\/{/ baz = //{// - // The following is known to be broken + // The following is no longer broken \o/ /function() {/ - return - } + return diff --git a/tests/suite/js.tokens b/tests/suite/js.tokens index b88effa..c4adaa2 100644 --- a/tests/suite/js.tokens +++ b/tests/suite/js.tokens @@ -433,7 +433,7 @@ Line([Open('