Merge pull request #3107 from xinnan-tech/py-fix-tts-markdown

fix: 调整处理顺序保留英文空格的同时修复markdown被识别为纯ASCII 字符的错误返回
This commit is contained in:
wengzh
2026-04-17 11:02:53 +08:00
committed by GitHub
+5 -5
View File
@@ -130,17 +130,17 @@ class MarkdownCleaner:
"""
主入口方法:依序执行所有正则,移除或替换 Markdown 元素
"""
# 检查文本是否全为英文和基本标点符号
if text and all((c.isascii() or c.isspace() or c in punctuation_set) for c in text):
# 保留原始空格,直接返回
return text
for regex, replacement in MarkdownCleaner.REGEXES:
text = regex.sub(replacement, text)
# 去除emoji表情
text = check_emoji(text)
# 检查文本是否全为英文和基本标点符号
if text and all((c.isascii() or c.isspace() or c in punctuation_set) for c in text):
# 保留原始空格,直接返回
return text
return text.strip()
def convert_percentage_to_range(percentage, min_val, max_val, base_val=None):