mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-02-20 13:03:42 +01:00
Fix and split regex
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
163bfe7c2c
commit
c1c90a6b3b
|
|
@ -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):
|
# A shortcode is defined as (newlines and whitespaces for presentation purpose):
|
||||||
#
|
#
|
||||||
# {{%
|
# {{%
|
||||||
# <one or more whitespaces>
|
# <zero or more whitespaces>
|
||||||
# <name of shortcode>
|
# <name of shortcode>
|
||||||
# <one or more whitespaces>
|
# (optional <one or more whitespaces><list of parameters>)
|
||||||
# (optional <list of parameters><one or more whitespaces>)
|
# <zero or more whitespaces>
|
||||||
# %}}
|
# %}}
|
||||||
#
|
#
|
||||||
# With:
|
# With:
|
||||||
|
|
@ -48,7 +48,12 @@ api_dir = os.path.join(os.path.dirname(scripts_dir), "data", "api")
|
||||||
# * <name of shortcode>: any word character and `-` and `/`.
|
# * <name of shortcode>: any word character and `-` and `/`.
|
||||||
# * <list of parameters>: any character except `}`, must not start or end with a
|
# * <list of parameters>: any character except `}`, must not start or end with a
|
||||||
# whitespace.
|
# whitespace.
|
||||||
shortcode_regex = re.compile(r"\{\{\%\s+(?P<name>[\w\/-]+)\s+(?:(?P<params>[^\s\}][^\}]+[^\s\}])\s+)?\%\}\}", re.ASCII)
|
shortcode_regex = re.compile(r"""\{\{\% # {{%
|
||||||
|
\s* # zero or more whitespaces
|
||||||
|
(?P<name>[\w/-]+) # name of shortcode
|
||||||
|
(?:\s+(?P<params>[^\s\}][^\}]+[^\s\}]))? # optional list of parameters
|
||||||
|
\s* # zero or more whitespaces
|
||||||
|
\%\}\} # %}}""", re.ASCII | re.VERBOSE)
|
||||||
|
|
||||||
# Parses the parameters of a Hugo shortcode.
|
# Parses the parameters of a Hugo shortcode.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue