将整个图片而不只是base64用占位符替换
This commit is contained in:
@@ -56,8 +56,13 @@ def uris2placeholder(markdown: str, mask_dict: MaskDict):
|
|||||||
##只替换uri里的链接部分,保留标题
|
##只替换uri里的链接部分,保留标题
|
||||||
def uri2placeholder(match: re.Match):
|
def uri2placeholder(match: re.Match):
|
||||||
id = mask_dict.create_id()
|
id = mask_dict.create_id()
|
||||||
mask_dict.set(id, match.group(2))
|
# 只替换base64数据
|
||||||
return f"{match.group(1)}(<ph-{id}>)"
|
# mask_dict.set(id, match.group(2))
|
||||||
|
# return f"{match.group(1)}(<ph-{id}>)"
|
||||||
|
|
||||||
|
#整个图片都替换为占位符
|
||||||
|
mask_dict.set(id, match.group())
|
||||||
|
return f"<ph-{id}>"
|
||||||
|
|
||||||
uri_pattern = r'(!?\[.*?\])\((.*?)\)'
|
uri_pattern = r'(!?\[.*?\])\((.*?)\)'
|
||||||
markdown = re.sub(uri_pattern, uri2placeholder, markdown)
|
markdown = re.sub(uri_pattern, uri2placeholder, markdown)
|
||||||
|
|||||||
Reference in New Issue
Block a user