I'm trying to convert html file to docx I tried pandoc but it seems that it can't add styles so are there any way to convert it to docx with the styles?
edit: I used pygments to highlight some code and wants to get it in docx file but it seems that docx output format not supported by pygments so I got the output as html
Asked
Active
Viewed 4,041 times
0

KyRillos BoshRa
- 11
- 1
- 5
2 Answers
4
No. From the pandoc MANUAL:
Because pandoc’s intermediate representation of a document is less expressive than many of the formats it converts between, one should not expect perfect conversions between every format and every other. Pandoc attempts to preserve the structural elements of a document, but not formatting details such as margin size.
You can however use the --reference-doc option and custom styles to style the docx output.

mb21
- 34,845
- 8
- 116
- 142
-
yes it seems that pandoc can't do it --reference-doc option takes docx file also which I don't have so it seems that I'm looking for another tool or python module to do it.. – KyRillos BoshRa Jun 17 '19 at 01:35
0
You can do this with python-docx by embedding the entire html document as an altChunk.

isparks
- 136
- 1
- 2
-
I hope I could find this answer earlier, as I had a very limited number of tags and styles I did it the hard way.. – KyRillos BoshRa Jun 26 '19 at 04:53