before changing links

This commit is contained in:
govardhan
2025-06-19 09:01:18 +05:30
commit 6686208bf1
1277 changed files with 29692 additions and 0 deletions

27
fix_image_paths.py Normal file
View File

@ -0,0 +1,27 @@
import os
import re
def fix_image_paths(file_path):
with open(file_path, 'r') as f:
content = f.read()
# Fix Logo image at the top
content = content.replace('[![Logo](_images/', '[![Logo](../_images/')
# Fix other image references
pattern = r'!\[\.\./_images/([^]]+)\]\(_images/([^)]+)\)'
content = re.sub(pattern, r'![\1](../_images/\2)', content)
with open(file_path, 'w') as f:
f.write(content)
def process_directory(dir_path):
for root, dirs, files in os.walk(dir_path):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)
fix_image_paths(file_path)
if __name__ == "__main__":
docs_dir = "/Users/dhanraj/Desktop/kpme_scraper/docs"
process_directory(docs_dir)