diff --git a/dsLightRag/ShiTi/T3_DocxToMd.py b/dsLightRag/ShiTi/T3_DocxToMd.py index 307e15ab..b9805f06 100644 --- a/dsLightRag/ShiTi/T3_DocxToMd.py +++ b/dsLightRag/ShiTi/T3_DocxToMd.py @@ -7,7 +7,8 @@ async def main(): # 要处理的文件路径 file_path = "Docx/《动能定理》巩固练习.docx" # 转换docx为md - get_docx_content_by_pandoc(file_path, '../Word转试题.md',extract_media='../static/Images/') + get_docx_content_by_pandoc(file_path, '../Word转试题.md', parent_dir=True) + if __name__ == "__main__": asyncio.run(main()) diff --git a/dsLightRag/Util/DocxUtil.py b/dsLightRag/Util/DocxUtil.py index d5f1784f..a76fd99e 100644 --- a/dsLightRag/Util/DocxUtil.py +++ b/dsLightRag/Util/DocxUtil.py @@ -3,7 +3,7 @@ import subprocess import uuid -def get_docx_content_by_pandoc(docx_file, output_file=None, extract_media=None): +def get_docx_content_by_pandoc(docx_file, output_file=None, parent_dir=None): # 最后拼接的内容 content = "" # output_file 设置为临时目录下的uuid.md @@ -11,10 +11,16 @@ def get_docx_content_by_pandoc(docx_file, output_file=None, extract_media=None): # 将docx_file去掉扩展名 prefix = docx_file.split(".")[0].split("/")[-1] temp_markdown = os.path.join('./static/markdown/', prefix + '.md') + if parent_dir: + temp_markdown = os.path.join('../static/markdown/', prefix + '.md') # 调用pandoc将docx文件转换成markdown - if extract_media is None: + if parent_dir is None: os.mkdir("./static/Images/" + file_name) extract_media = "./static/Images/" + else: + os.mkdir("../static/Images/" + file_name) + extract_media = "../static/Images/" + subprocess.run(['pandoc', docx_file, '-f', 'docx', '-t', 'markdown', '-o', temp_markdown, '--extract-media=' + extract_media + file_name]) # 读取然后修改内容,输出到新的文件 diff --git a/dsLightRag/Util/__pycache__/DocxUtil.cpython-310.pyc b/dsLightRag/Util/__pycache__/DocxUtil.cpython-310.pyc index a7cd04be..044dab59 100644 Binary files a/dsLightRag/Util/__pycache__/DocxUtil.cpython-310.pyc and b/dsLightRag/Util/__pycache__/DocxUtil.cpython-310.pyc differ diff --git a/dsLightRag/Word转试题.md b/dsLightRag/Word转试题.md index e738caeb..0123b7bb 100644 --- a/dsLightRag/Word转试题.md +++ b/dsLightRag/Word转试题.md @@ -1,6 +1,6 @@ 【题型】不定项选择 【题文】如图所示,固定斜面倾角为*θ*,整个斜面分为*AB*、*BC*两段,*AB*=2*BC*.小物块*P*(可视为质点)与*AB*、*BC*两段斜面间的动摩擦因数分别为*μ*~1~、*μ*~2~.已知*P*由静止开始从*A*点释放,恰好能滑动到*C*点而停下,那么*θ*、*μ*~1~、*μ*~2~间应满足的关系是(  ) -![5-40.tif](./static/Images/6855d84768e44d74ad95dfb7033bcf40/media/image1.png){width="0.9847222222222223in" +![5-40.tif](../static/Images/3a5fa82d1a614209a8b81f9321b21808/media/image1.png){width="0.9847222222222223in" height="0.6979166666666666in"}A.$tan\theta\text{=}\frac{\mu_{1} + 2\mu_{2}}{3}$ B.$tan\theta\text{=}\frac{2\mu_{1} + \mu_{2}}{3}$ C.$tan\theta\text{=}2\mu_{1} - \mu_{2}$ diff --git a/dsLightRag/static/Images/3a5fa82d1a614209a8b81f9321b21808/media/image1.png b/dsLightRag/static/Images/3a5fa82d1a614209a8b81f9321b21808/media/image1.png new file mode 100644 index 00000000..9e0e4c51 Binary files /dev/null and b/dsLightRag/static/Images/3a5fa82d1a614209a8b81f9321b21808/media/image1.png differ