Files
3engines_doc/fix_image_paths.py
2025-06-19 09:01:18 +05:30

28 lines
818 B
Python

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)