Pandoc convert html with stylesheet to docx

I banged my head about it for a few seconds, and I’m sure that the solution is quite simple or does not exist at all.

I am trying to convert 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 without problems, but I can not 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.

+5
source share
1 answer

In your command, "-c myfile.css" will only be used if you are writing HTML or HTML 5. This is an author-specific option.

To format docx 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

+3
source

All Articles