diff --git a/dsLightRag/ShiTi/T3_DocxToMd.py b/dsLightRag/ShiTi/T3_DocxToMd.py index 8265946d..8c3cb6ef 100644 --- a/dsLightRag/ShiTi/T3_DocxToMd.py +++ b/dsLightRag/ShiTi/T3_DocxToMd.py @@ -79,11 +79,13 @@ async def main(): """ 修正一下MinerU生成的Latex中,如果是数字加圆圈的样式 \textcircled{1},无法在Typora或者PyCharm中显示的问题,改成兼容性更强的 \enclose{circle}{1} """ - - finalName = r'D:\dsWork\dsProject\dsRagAnything\output\《动能定理》巩固练习\auto\《动能定理》巩固练习.md' + # \textcircled + finalName = r'D:\\dsWork\\dsProject\\dsRagAnything\\output\\《动能定理》巩固练习\\auto\\《动能定理》巩固练习.md' with open(finalName, 'r', encoding='utf-8') as f: content = f.read() - content = content.replace(r'\textcircled', r'\enclose{circle}') + # 使用正则表达式匹配可能包含空格的命令格式 + import re + content = re.sub(r'\\textcircled\s*\{([0-9]+)\}', r'\\enclose{circle}{\1}', content) with open(finalName, 'w', encoding='utf-8') as f: f.write(content)