i would like to detect enumerated list in a word document using python-docx. like
if paragraph is enum:
#do something
Is it possible in python-docx?
TIA
This might be an incomplete answer, but most of the enums or numbered lists have numbering properties reference (w:numPr) property within paragraph properties (w:pPr).
This code is listing all paragraphs which contain w:numPr within w:pPr:
[p for p in doc.paragraphs if len(p._element.xpath('./w:pPr/w:numPr')) > 0]
Hope this helps,
Best
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With