Skip to content

Commit 0be4be4

Browse files
committed
Do not add formattings if there's already one with the same tag
1 parent fbbd2f4 commit 0be4be4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

docxcompose/composer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,12 @@ def retain_formatting_from_default_styles(self, doc):
365365
# For every paragraph property without a style, we add the
366366
# formattings from the default style.
367367
for el in xpath(doc.element, ".//w:pPr[not(w:pStyle)]"):
368+
existing_tags = set(
369+
[child.tag for child in el.getchildren()]
370+
)
368371
for paragraph_property in paragraph_properties:
372+
if paragraph_property.tag in existing_tags:
373+
continue
369374
el.append(deepcopy(paragraph_property))
370375

371376
def add_styles(self, doc, element):

0 commit comments

Comments
 (0)