From dc419cfb2808005f5b2d0ba4631ebbfc0fe98268 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 15 Jun 2015 15:09:09 +0100 Subject: Add text box support --- tests/docx/document_xml_tests.py | 17 +++++++++++++++++ tests/mammoth_tests.py | 7 +++++++ tests/test-data/text-box.docx | Bin 0 -> 15850 bytes 3 files changed, 24 insertions(+) create mode 100755 tests/test-data/text-box.docx (limited to 'tests') diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py index 22b4c31..f0fa5ab 100644 --- a/tests/docx/document_xml_tests.py +++ b/tests/docx/document_xml_tests.py @@ -409,6 +409,23 @@ class ReadXmlElementTests(object): documents.run([documents.Text("Hello!")]), read_document_xml_element(element).value ) + + @istest + def text_boxes_have_content_appended_after_containing_paragraph(self): + text_box = xml_element("w:pict", {}, [ + xml_element("v:shape", {}, [ + xml_element("v:textbox", {}, [ + xml_element("w:txbxContent", {}, [ + _paragraph_with_style_id("textbox-content") + ]) + ]) + ]) + ]) + paragraph = xml_element("w:p", {}, [ + xml_element("w:r", {}, [text_box]) + ]) + result = _read_and_get_document_xml_element(paragraph) + assert_equal(result[1].style_id, "textbox-content") @istest def alternate_content_is_read_using_fallback(self): diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index d9f1093..18f7b48 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -102,6 +102,13 @@ def endnotes_are_appended_to_text(): assert_equal(expected_html, result.value) +@istest +def text_boxes_are_read(): + with open(test_path("text-box.docx"), "rb") as fileobj: + result = mammoth.convert_to_html(fileobj=fileobj) + assert_equal('

Datum plane

', result.value) + + @istest def transform_document_is_applied_to_document_before_conversion(): def transform_document(document): diff --git a/tests/test-data/text-box.docx b/tests/test-data/text-box.docx new file mode 100755 index 0000000..2d53703 Binary files /dev/null and b/tests/test-data/text-box.docx differ -- cgit v1.2.3