Closed
Description
导出MD时,图片左右两侧存在零宽空格字符
Is there an existing issue for this?
- I have searched the existing issues
Can the issue be reproduced with the default theme (daylight/midnight)?
- I was able to reproduce the issue with the default theme
Could the issue be due to extensions?
- I've ruled out the possibility that the extension is causing the problem.
Describe the problem
在使用 v3.1.23 版本导出文档,导出格式为 markdown 时,在图片左右处会出现零宽空格(&ZerowidthSpace):
Expected result
导出 MD 时,应删除零宽空格(&ZerowidthSpace)
Screenshot or screen recording presentation
For inline code, ZWPS changes to ZWNBSP: #11248
Version environment
- Version: v3.1.23
- Operating System: Windows 11
Log file
no log file
More information
我使用以下方法解决了这个问题:
import re
def remove_zero_width_chars(text):
"""替换所有常见的零宽度字符"""
return re.sub(r'[\u200B-\u200D\uFEFF]', '', text)
def remove_specific_chars(text):
"""替换特定的 Unicode 字符"""
text = text.replace('\u8203', '') # 替换 \u8203
text = text.replace('\uB200', '') # 替换 \uB200
return text
def trim_zero_width_chars(text):
"""替换开头和结尾的零宽度字符"""
return re.sub(r'^[\s\u200b]*|[\s\u200b]*$', '', text)
def process_file(file_path):
"""处理文件内容并覆盖原文件"""
try:
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# 依次应用处理逻辑
content = remove_zero_width_chars(content)
content = remove_specific_chars(content)
content = trim_zero_width_chars(content)
# 覆盖原文件
with open(file_path, 'w', encoding='utf-8') as file:
file.write(content)
print(f"文件 {file_path} 处理完成并已覆盖保存!")
except Exception as e:
print(f"处理文件时出错: {e}")
if __name__ == "__main__":
file_path = input("请输入要处理的文件路径: ")
process_file(file_path)
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]导出MD时,图片左右两侧存在零宽空格字符[/-][+]Remove zero-width spaces around image nodes when exporting Markdown[/+]🎨 Protyle Remove zero-width spaces around image nodes when exporting …
⬆️ Upgrade lute #14263
⬆️ Upgrade lute #14263
⬆️ Upgrade lute #14263
Merge commit '2d2420794c89a86e9cbbddbd05fc5edf17c26a7b'