aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--mammoth/docx/body_xml.py6
-rw-r--r--tests/docx/body_xml_tests.py33
3 files changed, 41 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 6f224b7..1bad17f 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
* Read the children of w:customXml elements.
+* Handle paragraphs and runs that have been moved and tracked as a revision.
+
# 1.12.2
* Avoid excessive backtracking when parsing an unterminated string with many
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index bf3e3ca..1a9b49e 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -72,6 +72,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
"w:del",
"w:footnoteRef",
"w:endnoteRef",
+ "w:moveFrom",
"w:pPr",
"w:rPr",
"w:tblPr",
@@ -698,6 +699,11 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
"w:tc": table_cell,
"w:customXml": read_child_elements,
"w:ins": read_child_elements,
+ "w:moveFromRangeEnd": read_child_elements,
+ "w:moveFromRangeStart": read_child_elements,
+ "w:moveTo": read_child_elements,
+ "w:moveToRangeEnd": read_child_elements,
+ "w:moveToRangeStart": read_child_elements,
"w:object": read_child_elements,
"w:smartTag": read_child_elements,
"w:drawing": read_child_elements,
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py
index 1bce6e1..58a036f 100644
--- a/tests/docx/body_xml_tests.py
+++ b/tests/docx/body_xml_tests.py
@@ -1292,6 +1292,21 @@ def test_children_of_w_custom_xml_are_converted_normally():
def test_children_of_w_ins_are_converted_normally():
_assert_children_are_converted_normally("w:ins")
+def test_children_of_w_move_from_range_end_are_converted_normally():
+ _assert_children_are_converted_normally("w:moveFromRangeEnd")
+
+def test_children_of_w_move_from_range_start_are_converted_normally():
+ _assert_children_are_converted_normally("w:moveFromRangeStart")
+
+def test_children_of_w_move_to_are_converted_normally():
+ _assert_children_are_converted_normally("w:moveTo")
+
+def test_children_of_w_move_to_range_end_are_converted_normally():
+ _assert_children_are_converted_normally("w:moveToRangeEnd")
+
+def test_children_of_w_move_to_range_start_are_converted_normally():
+ _assert_children_are_converted_normally("w:moveToRangeStart")
+
def test_children_of_w_object_are_converted_normally():
_assert_children_are_converted_normally("w:object")
@@ -1751,6 +1766,24 @@ def test_text_nodes_are_ignored_when_reading_children():
_read_and_get_document_xml_element(element)
)
+
+def test_w_move_from_elements_are_ignored():
+ _assert_element_is_ignored("w:moveFrom")
+
+
+def _assert_element_is_ignored(tag_name):
+ element = xml_element(tag_name, {}, [
+ xml_element("w:r", {}, [
+ xml_element("w:t", {}, [xml_text("Blackdown")])
+ ])
+ ])
+
+ assert_equal(
+ [],
+ _read_and_get_document_xml_elements(element)
+ )
+
+
def _read_and_get_document_xml_element(element, **kwargs):
elements = _read_and_get_document_xml_elements(element, **kwargs)
return single(elements)