问题
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