|
|
@ -35,9 +35,6 @@ def get_docx_content_by_pandoc(docx_file):
|
|
|
|
os.mkdir("../static/Images/" + file_name)
|
|
|
|
os.mkdir("../static/Images/" + file_name)
|
|
|
|
subprocess.run(['pandoc', docx_file, '-f', 'docx', '-t', 'markdown', '-o', temp_markdown,
|
|
|
|
subprocess.run(['pandoc', docx_file, '-f', 'docx', '-t', 'markdown', '-o', temp_markdown,
|
|
|
|
'--extract-media=../static/Images/' + file_name])
|
|
|
|
'--extract-media=../static/Images/' + file_name])
|
|
|
|
# 打印 temp_markdown 文件
|
|
|
|
|
|
|
|
# with open(temp_markdown, 'r', encoding='utf-8') as f:
|
|
|
|
|
|
|
|
# print(f.read())
|
|
|
|
|
|
|
|
# 读取然后修改内容,输出到新的文件
|
|
|
|
# 读取然后修改内容,输出到新的文件
|
|
|
|
wmf_idx = 0 # wmf索引
|
|
|
|
wmf_idx = 0 # wmf索引
|
|
|
|
img_idx = 0 # 图片索引
|
|
|
|
img_idx = 0 # 图片索引
|
|
|
@ -66,12 +63,10 @@ def get_docx_content_by_pandoc(docx_file):
|
|
|
|
pos = line.find(")")
|
|
|
|
pos = line.find(")")
|
|
|
|
q = line[:pos + 1]
|
|
|
|
q = line[:pos + 1]
|
|
|
|
img_idx += 1
|
|
|
|
img_idx += 1
|
|
|
|
# content += "【图片" + str(img_idx) + "】\n"
|
|
|
|
|
|
|
|
content += q + "\n"
|
|
|
|
content += q + "\n"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
content += line.strip().replace("**", "") + "\n"
|
|
|
|
content += line.strip().replace("**", "") + "\n"
|
|
|
|
|
|
|
|
|
|
|
|
# 删除临时文件 output_file
|
|
|
|
# 删除临时文件 output_file
|
|
|
|
# os.remove(temp_markdown)
|
|
|
|
os.remove(temp_markdown)
|
|
|
|
# print("生成的md文件路径:" + temp_markdown)
|
|
|
|
|
|
|
|
return content
|
|
|
|
return content
|
|
|
|