From 58dda28aff6a206884189c069291292a592e2ca6 Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Mon, 30 Jan 2023 10:52:41 +0000 Subject: [PATCH] Fix link rewrites Update the sync script to ensure both links and images are processed for URL rewrites. --- sync/sync.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sync/sync.py b/sync/sync.py index bfe19bb..710fff4 100755 --- a/sync/sync.py +++ b/sync/sync.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright 2020 The Tekton Authors +# Copyright 2020-2023 The Tekton Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -239,11 +239,13 @@ def transform_links_doc(text, base_path, local_files, rewrite_path, rewrite_url) """ transform all the links the text """ links = get_links(text) # Rewrite map, only use links with href and src - rewrite_map = {x.get("href"): transform_link(x.get("href"), base_path, local_files, rewrite_path, rewrite_url) + rewrite_map_links = {x.get("href"): transform_link(x.get("href"), base_path, local_files, rewrite_path, rewrite_url) for x in links if x.get("href")} - rewrite_map = {x.get("src"): transform_link(x.get("src"), base_path, local_files, rewrite_path, rewrite_url) + rewrite_map_images = {x.get("src"): transform_link(x.get("src"), base_path, local_files, rewrite_path, rewrite_url) for x in links if x.get("src")} + rewrite_map = {**rewrite_map_links, **rewrite_map_images} + for source, target in rewrite_map.items(): text = text.replace(f'({source})', f'({target})') return text -- GitLab