KyRillos BoshRa
KyRillos BoshRa

Reputation: 21

convert html to docx without losing styles

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

Upvotes: 0

Views: 6157

Answers (2)

isparks
isparks

Reputation: 166

You can do this with python-docx by embedding the entire html document as an altChunk.

How to add w:altChunk and its relationship with python-docx

Upvotes: 0

mb21
mb21

Reputation: 39546

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.

Upvotes: 4

Related Questions