diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/generate_card_hover_links.py | 21 |
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__': |
