aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-09-03 14:06:36 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-09-03 14:06:36 +0200
commitae9775a41981b211a00244ddbacb84934cf9383a (patch)
treeee29964c553f1cfa1dc9f47055b6bb208e3bd765 /scripts
parent6565ed7e4e950151e227774611372da4c80383aa (diff)
downloadmuhqs-game-ae9775a41981b211a00244ddbacb84934cf9383a.tar.gz
muhqs-game-ae9775a41981b211a00244ddbacb84934cf9383a.zip
use "../" as default placeholder_png_prefix
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_card_hover_links.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/scripts/generate_card_hover_links.py b/scripts/generate_card_hover_links.py
index aae1de51..abf32295 100755
--- a/scripts/generate_card_hover_links.py
+++ b/scripts/generate_card_hover_links.py
@@ -56,7 +56,7 @@ def gen_hoverable_link(card: str,
gen_link_target: GenLinkTargetCallback,
images_path: str,
language: str,
- placeholder_png_prefix="") -> str:
+ placeholder_png_prefix="../") -> str:
"""Return the hoverable link generated for the match
:param card: the card name
@@ -64,6 +64,7 @@ def gen_hoverable_link(card: str,
:param gen_link_target: a Callable returning the link target as string
:param images_path: path to where the rendered images are stored
:param language: the language
+ :param placeholder_png_prefix: prefix of the path to the placeholder png
:returns: the code of the hoverable link
"""
link_text = gen_link_text(card)
@@ -96,7 +97,8 @@ def gen_link_to_cardlisting(card: str, language: str, path_prefix='') -> str:
def replace_all_links(string: str,
images_path: str,
language='en',
- link_path_prefix='') -> str:
+ link_path_prefix='',
+ placeholder_png_prefix='../') -> str:
"""Replace a document containing all included cards"""
def gen_link_text(card):
@@ -105,8 +107,12 @@ def replace_all_links(string: str,
def sub_func(match):
return gen_hoverable_link(
match.group('card'),
- gen_link_text, lambda card, lang: gen_link_to_cardlisting(
- card, lang, link_path_prefix), images_path, language)
+ gen_link_text,
+ lambda card, lang: gen_link_to_cardlisting(card, lang,
+ link_path_prefix),
+ images_path,
+ language,
+ placeholder_png_prefix=placeholder_png_prefix)
return re.sub(PATTERN, sub_func, string)
@@ -131,6 +137,10 @@ def main():
default='',
type=str,
help='a prefix to the path to the cardlisting')
+ parser.add_argument('--placeholder-path-prefix',
+ default='../',
+ type=str,
+ help='a prefix to the path to the cardlisting')
args = parser.parse_args()
@@ -146,7 +156,8 @@ def main():
replace_all_links(content,
args.images,
language=args.language,
- link_path_prefix=args.cardlisting_path_prefix))
+ link_path_prefix=args.cardlisting_path_prefix,
+ placeholder_png_prefix=args.placeholder_path_prefix))
if __name__ == '__main__':