import re
def process_markdown_content(content):
img_pattern = re.compile(r'!\[([^\]]*)\]\((\./[^)]+)\)')
# 对每个链接进行处理
def replacer(match):
description = match.group(1)
old_path = match.group(2)
# 改图片链接为新的文件夹
new_path = old_path.replace('./', './new_folder/')
return f''
# 替换原链接为新链接
new_content = img_pattern.sub(replacer, content)
return new_content
# 示例
markdown_content = '''
Here is some markdown content.


'''
new_content = process_markdown_content(markdown_content)
new_content