l2s*_*ver 11 html converter docx pandoc
我一直在敲打这个问题几个小时,我确信解决方案很简单,或者根本不存在.
我正在尝试将html文件转换为docx!
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #d0e4fe;
}
h1 {
color: orange;
text-align: center;
}
p {
font-family: "Times New Roman";
font-size: 20px;
}
</style>
</head>
<body>
<h1>My First CSS Example</h1>
<p>This is a paragraph.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我可以转换它没有问题,但我不能让风格坚持下去.
pandoc -s myfile.html -o test64.docx
pandoc -s -c myfile.css myfile.html -o test64.docx
Run Code Online (Sandbox Code Playgroud)
请救救我
在您的命令中,只有在编写HTML或HTML 5时才会使用"-c myfile.css".它是特定于编写器的选项.
对于docx格式,您需要创建".docx"模板.
首先运行pandoc -D docx > my_template.docx然后编辑my_template.docx中的样式.
终于跑了 pandoc -s myfile.html --template=my_template -o test64.docx
以上答案不再有效。根据文档,您现在可以使用以下方法生成模板:
pandoc --print-default-data-file reference.docx > custom-reference.docx
Run Code Online (Sandbox Code Playgroud)
有关如何使用模板的完整文档,请转到文档并搜索“ --reference-doc”