pandoc将html与样式表转换为docx [英] pandoc convert html with style sheet to docx

查看:3366
本文介绍了pandoc将html与样式表转换为docx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为这个问题敲响头几个小时,我确信解决方案很简单,或者根本不存在。



我试图将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>我的第一个CSS范例< / h1>
< p>这是一段。< / p>

< / body>
< / html>

我可以将它转换成没有问题,但我无法使样式保持原样。

  pandoc -s myfile.html -o test64.docx 
pandoc -s -c myfile.css myfile.html -o test64 .docx

请保存我。 解决方案

在您的命令中,-c myfile.css只会在您写入HTML或HTML 5时使用。它是一个特定于作者的选项。



对于docx格式化,您需要创建一个.docx模板。

首先运行 pandoc -D docx> ; my_template.docx 然后编辑my_template.docx中的样式。



最后运行 pandoc -s myfile.html - -template = my_template -o test64.docx


I've been banging my head on this one for a few hours, and I'm sure the solution is quite simple, or non-existent.

I'm trying to convert an html file to 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>

I can convert it no problem, but I can't get the styles to stick.

pandoc -s myfile.html -o test64.docx
pandoc -s -c myfile.css myfile.html -o test64.docx

Please save me.

解决方案

In your command the "-c myfile.css" would only be used if you were writing to HTML or HTML 5. It is a writer specific option.

For docx formatting you need to create a ".docx" template.

Start by running pandoc -D docx > my_template.docx and then edit the styles in my_template.docx.

Finally run pandoc -s myfile.html --template=my_template -o test64.docx

这篇关于pandoc将html与样式表转换为docx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆