main
HuangHai 2 weeks ago
parent 4ba35fd79e
commit 252fe44713

@ -18,7 +18,7 @@ def get_latex_list(docx_file):
return res
with open(output, 'r', encoding='utf-8') as file:
for i, line in enumerate(file):
res.append(line.strip().replace("$$",""))
res.append(line.strip().replace("$$", ""))
return res
@ -29,11 +29,12 @@ def get_docx_content_by_pandoc(docx_file):
# 最后拼接的内容
content = ""
# output_file 设置为临时目录下的uuid.md
file_name=uuid.uuid4().hex
temp_markdown = os.path.join(os.environ['TEMP'], file_name + '.md')
file_name = uuid.uuid4().hex
temp_markdown = os.path.join('../static/markdown/', file_name + '.md')
# 调用pandoc将docx文件转换成markdown
os.mkdir("../static/Images/"+file_name)
subprocess.run(['pandoc', docx_file, '-f', 'docx', '-t', 'markdown', '-o', temp_markdown,'--extract-media=../static/Images/'+file_name])
os.mkdir("../static/Images/" + file_name)
subprocess.run(['pandoc', docx_file, '-f', 'docx', '-t', 'markdown', '-o', temp_markdown,
'--extract-media=../static/Images/' + file_name])
# 打印 temp_markdown 文件
# with open(temp_markdown, 'r', encoding='utf-8') as f:
# print(f.read())
@ -49,8 +50,8 @@ def get_docx_content_by_pandoc(docx_file):
if line.startswith('height=') and line.endswith('in"}'):
continue
# 使用find()方法安全地检查图片模式
is_wmf = line.find("![](media/image") >= 0 and line.find(".wmf") > 0
is_img = line.find("![](media/image") >= 0 and (
is_wmf = line.find("![](") >= 0 and line.find(".wmf") > 0
is_img = line.find("![](") >= 0 and (
line.find(".png") > 0 or
line.find(".jpg") > 0 or
line.find(".jpeg") > 0
@ -59,14 +60,18 @@ def get_docx_content_by_pandoc(docx_file):
content += formula_list[wmf_idx] + "\n"
wmf_idx += 1
elif is_img:
#![](media/image3.png){width="3.1251607611548557in"
# ![](media/image3.png){width="3.1251607611548557in"
# height="3.694634733158355in"}
# ![](../static/Images/01b20e04085e406ea5375791da58a60f/media/image3.png){width="3.1251607611548557in"
pos = line.find(")")
q = line[:pos + 1]
img_idx += 1
content += "【图片" + str(img_idx) + "\n"
# content += "【图片" + str(img_idx) + "】\n"
content += q + "\n"
else:
content += line.strip().replace("**","") + "\n"
content += line.strip().replace("**", "") + "\n"
# 删除临时文件 output_file
# os.remove(temp_markdown)
print("生成的md文件路径"+temp_markdown)
# print("生成的md文件路径" + temp_markdown)
return content

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/01b20e04085e406ea5375791da58a60f/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/01b20e04085e406ea5375791da58a60f/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/01b20e04085e406ea5375791da58a60f/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/1145be2d92ee4ba3a34d3d6e5bfc70b7/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/1145be2d92ee4ba3a34d3d6e5bfc70b7/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/1145be2d92ee4ba3a34d3d6e5bfc70b7/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/123d1b305bf64e6bb2cc82d9d0d3fa65/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/123d1b305bf64e6bb2cc82d9d0d3fa65/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/123d1b305bf64e6bb2cc82d9d0d3fa65/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/1b64a41486bb4d11ab7c9836a20ffd6c/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/1b64a41486bb4d11ab7c9836a20ffd6c/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/1b64a41486bb4d11ab7c9836a20ffd6c/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/6579a66db8bb412d9404f238f6ab91e4/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/6579a66db8bb412d9404f238f6ab91e4/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/6579a66db8bb412d9404f238f6ab91e4/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/7913b78204434dbb95b166dcee7411d8/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/7913b78204434dbb95b166dcee7411d8/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/7913b78204434dbb95b166dcee7411d8/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/896b87d8709c467482e429f840d42221/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/896b87d8709c467482e429f840d42221/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/896b87d8709c467482e429f840d42221/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/9da838f62187453096cb226e73e39d87/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/9da838f62187453096cb226e73e39d87/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/9da838f62187453096cb226e73e39d87/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/9f37754f975b43eda5f301951f701eab/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/9f37754f975b43eda5f301951f701eab/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/9f37754f975b43eda5f301951f701eab/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/c3498286f5a14ec6919c7fe39b9048f7/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/c3498286f5a14ec6919c7fe39b9048f7/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/c3498286f5a14ec6919c7fe39b9048f7/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/d156806371c947cb808aa11bbd51f1f8/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/d156806371c947cb808aa11bbd51f1f8/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/d156806371c947cb808aa11bbd51f1f8/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/e0a7a37008f84b1781917965c6abc454/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/e0a7a37008f84b1781917965c6abc454/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/e0a7a37008f84b1781917965c6abc454/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/f11ed209e8964cd0a826a67e53e7d6bd/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/f11ed209e8964cd0a826a67e53e7d6bd/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/f11ed209e8964cd0a826a67e53e7d6bd/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}

@ -0,0 +1,12 @@
问题1 氧化铁和硝酸的反应方程式
![](../static/Images/f50f1e818eae49fcaa7fd02aafb2e46a/media/image1.wmf)
问题2 氢气与氧气燃烧的方程式
.![](../static/Images/f50f1e818eae49fcaa7fd02aafb2e46a/media/image2.wmf).
问题3 我是一个图片
![](../static/Images/f50f1e818eae49fcaa7fd02aafb2e46a/media/image3.png){width="3.1251607611548557in"
height="3.694634733158355in"}
Loading…
Cancel
Save