Convert html to docx using pandoc

三世轮回 提交于 2019-12-22 09:00:31

问题


I trying to convert this html

<p><font color = \"#808080\">SHILPI</p>

to docx using pandoc with this command

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

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.


回答1:


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.

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




回答2:


Try:

pandoc  -s -S test.htm -o test.docx

Reference: http://pandoc.org/demos.html




回答3:


This inspection highlights deprecated HTML tags and provides ability to replace them with CSS or with other tags for some of them. Maybe better use this: <p style="color: #808080">SHILPI</p>



来源:https://stackoverflow.com/questions/32755607/convert-html-to-docx-using-pandoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!