aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-23 23:55:30 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-23 23:55:30 +0000
commitdd055e1396bba2177ada8ac4b05d7e87ccc8b780 (patch)
treea786eb916884e9487a8a2c927f0be623156533ca
parent157e87ce9e6b38dd351f3f000bfeee46a8f2f091 (diff)
Read children of w:smartTag
-rw-r--r--mammoth/docx/document_xml.py9
-rw-r--r--tests/docx/document_xml_tests.py12
2 files changed, 15 insertions, 6 deletions
diff --git a/mammoth/docx/document_xml.py b/mammoth/docx/document_xml.py
index 14d36a6..e4682a6 100644
--- a/mammoth/docx/document_xml.py
+++ b/mammoth/docx/document_xml.py
@@ -100,7 +100,9 @@ def _create_reader(numbering, content_types, relationships, docx_file):
@handler("w:ins")
- def ins(element):
+ @handler("w:smartTag")
+ @handler("w:drawing")
+ def read_child_elements(element):
return _read_xml_elements(element.children)
@@ -114,11 +116,6 @@ def _create_reader(numbering, content_types, relationships, docx_file):
href = relationships[relationship_id].target
return children_result.map(lambda children: documents.hyperlink(href, children))
-
- @handler("w:drawing")
- def drawing(element):
- return _read_xml_elements(element.children)
-
@handler("wp:inline")
@handler("wp:anchor")
def inline(element):
diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py
index 75b0e20..caeaeb8 100644
--- a/tests/docx/document_xml_tests.py
+++ b/tests/docx/document_xml_tests.py
@@ -130,6 +130,18 @@ class ReadXmlElementTests(object):
)
@istest
+ def children_of_w_smart_tag_are_converted_normally(self):
+ element = xml_element("w:p", {}, [
+ xml_element("w:smartTag", {}, [
+ xml_element("w:r")
+ ])
+ ])
+ assert_equal(
+ documents.paragraph([documents.run([])]),
+ _read_and_get_document_xml_element(element)
+ )
+
+ @istest
def hyperlink_is_read_if_it_has_a_relationship_id(self):
relationships = Relationships({
"r42": Relationship(target="http://example.com")