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. #