aboutsummaryrefslogtreecommitdiff
path: root/mammoth
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-08-03 07:59:33 +0100
committerMichael Williamson <mike@zwobble.org>2025-08-03 08:00:07 +0100
commit70e02c723496d32196dd0323258fb2270d38bbed (patch)
tree2a4dbbae8423e00be44cb5337ce15add8e7f3559 /mammoth
parentbb0ff1066ea8f890f98092244d1b489ceab7c80e (diff)
Ignore style definitions using a style ID that has already been used
Diffstat (limited to 'mammoth')
-rw-r--r--mammoth/docx/styles_xml.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/mammoth/docx/styles_xml.py b/mammoth/docx/styles_xml.py
index 0b3f39d..3178553 100644
--- a/mammoth/docx/styles_xml.py
+++ b/mammoth/docx/styles_xml.py
@@ -67,7 +67,18 @@ def read_styles_xml_element(element):
style = _read_style_element(style_element)
style_set = styles.get(element_type)
- if style_set is not None:
+
+ # Per 17.7.4.17 style (Style Definition) of ECMA-376 4th edition Part 1:
+ #
+ # > If multiple style definitions each declare the same value for their
+ # > styleId, then the first such instance shall keep its current
+ # > identifier with all other instances being reassigned in any manner
+ # > desired.
+ #
+ # For the purpose of conversion, there's no point holding onto styles
+ # with reassigned style IDs, so we ignore such style definitions.
+
+ if style_set is not None and style.style_id not in style_set:
style_set[style.style_id] = style
return Styles(