使用 pandoc 将 html 转换为 docx [英] Convert html to docx using pandoc

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

问题描述

我正在尝试转换此 html

I trying to convert this html

<p>

通过此命令使用 pandoc 到 docx

to docx using pandoc with this command

pandoc -s -o "test.docx" -t html5 -t docx html_file

但是它丢失的颜色,我只得到文本,据我所知,我认为 html 代码是正确的,因为当我使用 wkhtmltopdf 将相同的 html 转换为 pdf 时,它给出了正确的颜色.可能是什么问题?提前致谢.

But its losing colors, I am getting only text, as far as I know I think html code is correct because when I am using wkhtmltopdf to convert same html to pdf it gives the proper color. What can be the issue ? Thanks in advance.

推荐答案

Pandoc 不是这样工作的,它不理解 CSS,只理解 HTML/Markdown.它保留内容,但不保留布局等,请参阅语义 HTML.

That's not how Pandoc works, it doesn't understand CSS, only HTML/Markdown. It preserves the content, but not the layout etc, see semantic HTML.

但是,您可以使用模板来一致地设置输出样式.使用 Word 有点复杂,但您可以使用 --reference-doc 选项,效果基本相同.

You can, however, use templates to style your output consistently. With Word it's a bit more complicated but you can use the --reference-doc option for mostly the same effect.

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

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