aboutsummaryrefslogtreecommitdiff
path: root/mammoth/conversion.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 17:25:23 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 17:25:23 +0000
commitf5595b78f59d3f3a04c4e83702114dc2704f808a (patch)
treebb58b9fc9fc28ac81f7d96f1c48a2cbf9f09968a /mammoth/conversion.py
parenta5574fbb4540ca31ab0d4c639f6cd2a633e749fc (diff)
Match document matchers with numbering correctly
Diffstat (limited to 'mammoth/conversion.py')
-rw-r--r--mammoth/conversion.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py
index 3f30b22..87e1bf9 100644
--- a/mammoth/conversion.py
+++ b/mammoth/conversion.py
@@ -103,9 +103,7 @@ class DocumentConverter(object):
def _find_html_path(self, element, element_type, default):
for style in self._styles:
document_matcher = style.document_matcher
- if document_matcher.element_type == element_type and (
- document_matcher.style_name is None or
- document_matcher.style_name == element.style_name):
+ if _document_matcher_matches(document_matcher, element, element_type):
return style.html_path
if element.style_name is not None:
@@ -113,3 +111,15 @@ class DocumentConverter(object):
return default
+
+def _document_matcher_matches(matcher, element, element_type):
+ return (
+ matcher.element_type == element_type and (
+ matcher.style_name is None or
+ matcher.style_name == element.style_name
+ ) and (
+ element_type != "paragraph" or
+ matcher.numbering is None or
+ matcher.numbering == element.numbering
+ )
+ )