mwilliamson / python-mammoth

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

Multilevel class not converting #83

Closed rageshchalil closed 4 years ago

rageshchalil commented 4 years ago

Have a word document with have multi-level styles, which does not seem to convert properly. attaching here a sample.

sample.docx

Another question I have is regarding the multi-level ordered list and numbered lists, and the level can go deep to 6 at least. Is there a standard way of writing this?

rageshchalil commented 4 years ago

@mwilliamson can you please help with this issue here?

mwilliamson commented 4 years ago

I'm not sure what behaviour you're expecting. What is the HTML you're expecting?

rageshchalil commented 4 years ago

@mwilliamson Should like this: < div class = "wrapperbody" > Some data on body class. A bold text here. Remaining part of the text. For < div class="nonexistent" >[or see accompanying or see attached — pick appropriate location]< / div > full Information available on guide. those of their respective owners. < /div >

mwilliamson commented 4 years ago

You'll need to mark up the different sections of text using different styles in Word, and convert those Word styles to CSS classes using style mappings.

rageshchalil commented 4 years ago

Thanks for your response @mwilliamson, my question was how do we write style map when we have multi-level custom style document. In this case "bodyisi" and "IGNORE" which is inside the earlier one.

mwilliamson commented 4 years ago

I'm not sure what you mean by "multi-level" in this case. It seems like you'd want something like:

p[style-name='IGNORE'] => !
r[style-name='IGNORE char'] => !

to ignore those styles.

rageshchalil commented 4 years ago

@mwilliamson, this kind of helped me resolve my issues. how can I know various type of rules that I can set in custom maps? eg: the one you set above with => !

mwilliamson commented 4 years ago

The rules are documented in the README: https://github.com/mwilliamson/python-mammoth#writing-style-maps