From c1c90a6b3bdb5ce916f3f36ee7fd73f656089ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 6 May 2025 11:20:56 +0200 Subject: [PATCH] Fix and split regex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- scripts/dump-openapi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/dump-openapi.py b/scripts/dump-openapi.py index 0df4ce92..3b57d5de 100755 --- a/scripts/dump-openapi.py +++ b/scripts/dump-openapi.py @@ -37,10 +37,10 @@ api_dir = os.path.join(os.path.dirname(scripts_dir), "data", "api") # A shortcode is defined as (newlines and whitespaces for presentation purpose): # # {{% -# +# # -# -# (optional ) +# (optional ) +# # %}} # # With: @@ -48,7 +48,12 @@ api_dir = os.path.join(os.path.dirname(scripts_dir), "data", "api") # * : any word character and `-` and `/`. # * : any character except `}`, must not start or end with a # whitespace. -shortcode_regex = re.compile(r"\{\{\%\s+(?P[\w\/-]+)\s+(?:(?P[^\s\}][^\}]+[^\s\}])\s+)?\%\}\}", re.ASCII) +shortcode_regex = re.compile(r"""\{\{\% # {{% + \s* # zero or more whitespaces + (?P[\w/-]+) # name of shortcode + (?:\s+(?P[^\s\}][^\}]+[^\s\}]))? # optional list of parameters + \s* # zero or more whitespaces + \%\}\} # %}}""", re.ASCII | re.VERBOSE) # Parses the parameters of a Hugo shortcode. #