Skip to content

Commit 2f2e397

Browse files
committed
Convert relative links to raw GitHub links [automated]
1 parent 31cdbfe commit 2f2e397

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

replace_links.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,65 +23,65 @@ def main():
2323
# Pattern 1: HTML img tags with relative paths
2424
content = re.sub(
2525
r'<img([^>]*?)src="\.\.?/([^"]*)"',
26-
f'<img\\1src="{base_url}\\2?raw=true"',
26+
f'<img\\1src="{base_url}\\2"',
2727
content
2828
)
2929

3030
# Pattern 1b: Fix existing raw.githubusercontent.com links with ../
3131
content = re.sub(
3232
r'<img([^>]*?)src="https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/\.\.?/([^"]*)"',
33-
f'<img\\1src="{base_url}\\4?raw=true"',
33+
f'<img\\1src="{base_url}\\4"',
3434
content
3535
)
3636

3737
# Pattern 1c: Fix existing raw.githubusercontent.com links without ../
3838
content = re.sub(
3939
r'<img([^>]*?)src="https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/([^"]*)"',
40-
f'<img\\1src="{base_url}\\4?raw=true"',
40+
f'<img\\1src="{base_url}\\4"',
4141
content
4242
)
4343

4444
# Pattern 2: Markdown image syntax
4545
content = re.sub(
4646
r'!\[([^\]]*?)\]\(\.\.?/([^)]*?)\)',
47-
f'![\\1]({base_url}\\2?raw=true)',
47+
f'![\\1]({base_url}\\2)',
4848
content
4949
)
5050

5151
# Pattern 2b: Fix existing raw.githubusercontent.com markdown images with ../
5252
content = re.sub(
5353
r'!\[([^\]]*?)\]\(https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/\.\.?/([^)]*?)\)',
54-
f'![\\1]({base_url}\\4?raw=true)',
54+
f'![\\1]({base_url}\\4)',
5555
content
5656
)
5757

5858
# Pattern 2c: Fix existing raw.githubusercontent.com markdown images without ../
5959
content = re.sub(
6060
r'!\[([^\]]*?)\]\(https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/([^)]*?)\)',
61-
f'![\\1]({base_url}\\4?raw=true)',
61+
f'![\\1]({base_url}\\4)',
6262
content
6363
)
6464

6565
# Pattern 3: Markdown links to images
6666
content = re.sub(
6767
r'\[([^\]]*?)\]\(\.\.?/([^)]*?\.(png|jpg|jpeg|gif|svg|webp))\)',
68-
f'[\\1]({base_url}\\2?raw=true)',
68+
f'[\\1]({base_url}\\2)',
6969
content,
7070
flags=re.IGNORECASE
7171
)
7272

7373
# Pattern 3b: Fix existing raw.githubusercontent.com markdown links with ../
7474
content = re.sub(
7575
r'\[([^\]]*?)\]\(https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/\.\.?/([^)]*?\.(png|jpg|jpeg|gif|svg|webp))\)',
76-
f'[\\1]({base_url}\\4?raw=true)',
76+
f'[\\1]({base_url}\\4)',
7777
content,
7878
flags=re.IGNORECASE
7979
)
8080

8181
# Pattern 3c: Fix existing raw.githubusercontent.com markdown links without ../
8282
content = re.sub(
8383
r'\[([^\]]*?)\]\(https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/[^/]+/([^)]*?\.(png|jpg|jpeg|gif|svg|webp))\)',
84-
f'[\\1]({base_url}\\4?raw=true)',
84+
f'[\\1]({base_url}\\4)',
8585
content,
8686
flags=re.IGNORECASE
8787
)

0 commit comments

Comments
 (0)