mwilliamson / python-mammoth

Convert Word documents (.docx files) to HTML
BSD 2-Clause "Simplified" License
785 stars 121 forks source link

Mapping a paragraph style to multiple html elements (e.g., bold and italics) #111

Closed deltamacht closed 2 years ago

deltamacht commented 2 years ago

I'm parsing a Word document with python-docx and inspecting the various styles that are present. I then want to take this information and build out a style_map for mammoth. However, I have styles which are both bold and italicized. I know how to map the style to either one of those two, but I do not know how to wrap paragraphs in both tags simultaneously. Is this possible with the style map, or do I need to create a custom mapping to a bold_italic style and then process that downstream?

deltamacht commented 2 years ago

Nevermind, figured it out. Thanks.

wenestam commented 2 years ago

Hello, I am currently also trying to understand this. Could you leave an example of mapping where you have 2 conditions required to be met? Eg: I would like Bold and Underlined text to be converted to "h2", how do I make the mapping to take into account both conditions?