Skip to content

Commit

Permalink
Fix link rewrites
Browse files Browse the repository at this point in the history
Update the sync script to ensure both links and images are processed
for URL rewrites.
  • Loading branch information
AlanGreene authored and tekton-robot committed Jan 31, 2023
1 parent 9856377 commit 58dda28
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sync/sync.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 58dda28

Please sign in to comment.