File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 22import re
33
44def main ():
5- if len (sys .argv ) != 5 :
6- print ("Usage: python3 script.py file repo_owner repo_name commit_sha" )
5+ if len (sys .argv ) != 6 :
6+ print ("Usage: python3 script.py file repo_owner repo_name commit_sha branch " )
77 sys .exit (1 )
88
99 file_path = sys .argv [1 ]
1010 repo_owner = sys .argv [2 ]
1111 repo_name = sys .argv [3 ]
1212 commit_sha = sys .argv [4 ]
13+ branch = sys .argv [5 ]
1314
14- base_url = f"https://raw.githubusercontent. com/{ repo_owner } /{ repo_name } /{ commit_sha } /"
15+ base_url = f"https://github. com/{ repo_owner } /{ repo_name } /blob/ { branch } /"
1516
1617 try :
1718 with open (file_path , 'r' , encoding = 'utf-8' ) as f :
@@ -22,21 +23,21 @@ def main():
2223 # Pattern 1: HTML img tags with relative paths
2324 content = re .sub (
2425 r'<img([^>]*?)src="(\.\.?/[^"]*)"' ,
25- f'<img\\ 1src="{ base_url } \\ 2"' ,
26+ f'<img\\ 1src="{ base_url } \\ 2?raw=true "' ,
2627 content
2728 )
2829
2930 # Pattern 2: Markdown image syntax
3031 content = re .sub (
3132 r'!\[([^\]]*?)\]\((\.\.?/[^)]*?)\)' ,
32- f'' ,
33+ f'' ,
3334 content
3435 )
3536
3637 # Pattern 3: Markdown links to images
3738 content = re .sub (
3839 r'\[([^\]]*?)\]\((\.\.?/[^)]*?\.(png|jpg|jpeg|gif|svg|webp))\)' ,
39- f'[\\ 1]({ base_url } \\ 2)' ,
40+ f'[\\ 1]({ base_url } \\ 2?raw=true )' ,
4041 content ,
4142 flags = re .IGNORECASE
4243 )
You can’t perform that action at this time.
0 commit comments