before changing links
This commit is contained in:
27
fix_image_paths.py
Normal file
27
fix_image_paths.py
Normal 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('[
|
||||
|
||||
# Fix other image references
|
||||
pattern = r'!\[\.\./_images/([^]]+)\]\(_images/([^)]+)\)'
|
||||
content = re.sub(pattern, r'', 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)
|
||||
Reference in New Issue
Block a user