def test_write(self): src = PROJECT_ROOT + "/tests/2type.docx" dst = PROJECT_ROOT + "/tests/2type-test.docx" shutil.copyfile(src=src, dst=dst) to_latex(dst, repl="[latex]{0}[/latex]")
from docx import to_latex to_latex(filename='E:\\docx\\docx\\1.docx')
def test_write(self): src = PROJECT_ROOT + '/tests/tttt.docx' dst = PROJECT_ROOT + '/tests/tttt-test.docx' shutil.copyfile(src=src, dst=dst) to_latex(dst, repl='{0}')
global imgIndex # 声明imgIndex为全局变量 imgIndex = imgIndex + 1 img_file_name = inputFile + "-" + str(imgIndex) + "." + img_type #print img_file_name base64ToFile(img_data, img_file_name) return { #"relative-src": "../images/"+img_file_name, "src": os.path.abspath( os.path.join(os.path.abspath(inputFile), os.pardir, os.pardir, "images/", os.path.basename(img_file_name))) } #替换docx中的公式为latex to_latex(filename=inputFile) """ 生成html """ def gen_html(): document = u"<!DOCTYPE html><html lang='zh_CN'><head><meta charset='UTF-8'><title>Document</title><style>table,table td,table th{border:1px solid;border-collapse: collapse;}</style></head><body>" #print type(document) style_map = "u => u" with open(inputFile, "rb") as docx_file: result = mammoth.convert_to_html( docx_file, convert_image=mammoth.images.img_element(convert_image), style_map=style_map) html = result.value
def test_write(self): src = PROJECT_ROOT + '/tests/simple.docx' dst = PROJECT_ROOT + '/tests/simple-test.docx' shutil.copyfile(src=src, dst=dst) to_latex(dst, repl='[latex]{0}[/latex]')