mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-02-20 04:53:42 +01:00
Remove trailing whitespaces
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
parent
73b1936dae
commit
69adb6b270
|
|
@ -50,7 +50,7 @@ api_dir = os.path.join(os.path.dirname(scripts_dir), "data", "api")
|
||||||
# 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+(?P<name>[\w\/-]+)\s+(?:(?P<params>[^\s\}][^\}]+[^\s\}])\s+)?\%\}\}", re.ASCII)
|
||||||
|
|
||||||
# Parses the parameters of a Hugo shortcode.
|
# Parses the parameters of a Hugo shortcode.
|
||||||
#
|
#
|
||||||
# For simplicity, this currently only supports the `key="value"` format.
|
# For simplicity, this currently only supports the `key="value"` format.
|
||||||
shortcode_params_regex = re.compile(r"(?P<key>\w+)=\"(?P<value>[^\"]+)\"", re.ASCII)
|
shortcode_params_regex = re.compile(r"(?P<key>\w+)=\"(?P<value>[^\"]+)\"", re.ASCII)
|
||||||
|
|
@ -73,7 +73,7 @@ def replace_match(text, match, replacement):
|
||||||
|
|
||||||
def replace_shortcode(text, shortcode):
|
def replace_shortcode(text, shortcode):
|
||||||
"""Replaces the shortcode by a Markdown fallback in the text.
|
"""Replaces the shortcode by a Markdown fallback in the text.
|
||||||
|
|
||||||
The supported shortcodes are:
|
The supported shortcodes are:
|
||||||
|
|
||||||
* boxes/note, boxes/rationale, boxes/warning
|
* boxes/note, boxes/rationale, boxes/warning
|
||||||
|
|
@ -83,7 +83,7 @@ def replace_shortcode(text, shortcode):
|
||||||
if shortcode['name'].startswith("/"):
|
if shortcode['name'].startswith("/"):
|
||||||
# This is the end of the shortcode, just remove it.
|
# This is the end of the shortcode, just remove it.
|
||||||
return replace_match(text, shortcode['match'], "")
|
return replace_match(text, shortcode['match'], "")
|
||||||
|
|
||||||
match shortcode['name']:
|
match shortcode['name']:
|
||||||
case "boxes/note":
|
case "boxes/note":
|
||||||
text = replace_match(text, shortcode['match'], "**NOTE:** ")
|
text = replace_match(text, shortcode['match'], "**NOTE:** ")
|
||||||
|
|
@ -95,13 +95,13 @@ def replace_shortcode(text, shortcode):
|
||||||
version = shortcode['params']['v']
|
version = shortcode['params']['v']
|
||||||
if not version:
|
if not version:
|
||||||
raise ValueError("Missing parameter `v` for `added-in` shortcode")
|
raise ValueError("Missing parameter `v` for `added-in` shortcode")
|
||||||
|
|
||||||
text = replace_match(text, shortcode['match'], f"**[Added in `v{version}`]** ")
|
text = replace_match(text, shortcode['match'], f"**[Added in `v{version}`]** ")
|
||||||
case "changed-in":
|
case "changed-in":
|
||||||
version = shortcode['params']['v']
|
version = shortcode['params']['v']
|
||||||
if not version:
|
if not version:
|
||||||
raise ValueError("Missing parameter `v` for `changed-in` shortcode")
|
raise ValueError("Missing parameter `v` for `changed-in` shortcode")
|
||||||
|
|
||||||
text = replace_match(text, shortcode['match'], f"**[Changed in `v{version}`]** ")
|
text = replace_match(text, shortcode['match'], f"**[Changed in `v{version}`]** ")
|
||||||
case _:
|
case _:
|
||||||
raise ValueError("Unknown shortcode", shortcode['name'])
|
raise ValueError("Unknown shortcode", shortcode['name'])
|
||||||
|
|
@ -111,7 +111,7 @@ def replace_shortcode(text, shortcode):
|
||||||
|
|
||||||
def find_and_replace_shortcodes(text):
|
def find_and_replace_shortcodes(text):
|
||||||
"""Finds Hugo shortcodes and replaces them by a Markdown fallback.
|
"""Finds Hugo shortcodes and replaces them by a Markdown fallback.
|
||||||
|
|
||||||
The supported shortcodes are:
|
The supported shortcodes are:
|
||||||
|
|
||||||
* boxes/note, boxes/rationale, boxes/warning
|
* boxes/note, boxes/rationale, boxes/warning
|
||||||
|
|
@ -127,7 +127,7 @@ def find_and_replace_shortcodes(text):
|
||||||
for param in shortcode_params_regex.finditer(match['params']):
|
for param in shortcode_params_regex.finditer(match['params']):
|
||||||
if param['key']:
|
if param['key']:
|
||||||
params[param['key']] = param['value']
|
params[param['key']] = param['value']
|
||||||
|
|
||||||
shortcode = {
|
shortcode = {
|
||||||
'name': match['name'],
|
'name': match['name'],
|
||||||
'params': params,
|
'params': params,
|
||||||
|
|
@ -139,7 +139,7 @@ def find_and_replace_shortcodes(text):
|
||||||
|
|
||||||
def edit_descriptions(node, base_url):
|
def edit_descriptions(node, base_url):
|
||||||
"""Finds description nodes and apply fixes to them.
|
"""Finds description nodes and apply fixes to them.
|
||||||
|
|
||||||
The fixes that are applied are:
|
The fixes that are applied are:
|
||||||
|
|
||||||
* Make links absolute
|
* Make links absolute
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue