diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:49:04 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:49:04 +0100 |
| commit | 3bfa77d64e69d20609c8321a067bfa2651a7eabc (patch) | |
| tree | 4cab2b0ff450665c3b164a27292b18583c339059 /tests | |
| parent | 6478f5c20b86534c471793041f4e5b46f0cd6484 (diff) | |
Add support for strikethrough
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/conversion_tests.py | 8 | ||||
| -rw-r--r-- | tests/docx/document_xml_tests.py | 10 | ||||
| -rw-r--r-- | tests/mammoth_tests.py | 7 | ||||
| -rwxr-xr-x | tests/test-data/strikethrough.docx | bin | 0 -> 12652 bytes |
4 files changed, 25 insertions, 0 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index 19df77f..1563131 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -200,6 +200,14 @@ def style_mapping_for_underline_runs_does_not_close_parent_elements(): ] ) assert_equal("<strong><em>Hello</em></strong>", result.value) + + +@istest +def strikethrough_runs_are_wrapped_in_s_elements_by_default(): + result = convert_document_element_to_html( + documents.run(children=[documents.text("Hello")], is_strikethrough=True), + ) + assert_equal("<s>Hello</s>", result.value) @istest diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py index f0fa5ab..bc6fcfb 100644 --- a/tests/docx/document_xml_tests.py +++ b/tests/docx/document_xml_tests.py @@ -142,6 +142,16 @@ class ReadXmlElementTests(object): def run_is_underlined_if_underline_element_is_present(self): run = self._read_run_with_properties([xml_element("w:u")]) assert_equal(True, run.is_underline) + + @istest + def run_is_not_struckthrough_if_strikethrough_element_is_not_present(self): + run = self._read_run_with_properties([]) + assert_equal(False, run.is_strikethrough) + + @istest + def run_is_struckthrough_if_strikethrough_element_is_present(self): + run = self._read_run_with_properties([xml_element("w:strike")]) + assert_equal(True, run.is_strikethrough) @istest def run_has_baseline_vertical_alignment_if_vertical_alignment_element_is_not_present(self): diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index e7e7e64..84cb6ea 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -131,6 +131,13 @@ def underline_can_be_configured_with_style_mapping(): @istest +def strikethrough_is_converted_to_s_element_by_default(): + with open(test_path("strikethrough.docx"), "rb") as fileobj: + result = mammoth.convert_to_html(fileobj=fileobj) + assert_equal("<p><s>Today's Special: Salmon</s> Sold out</p>", result.value) + + +@istest def transform_document_is_applied_to_document_before_conversion(): def transform_document(document): document.children[0].style_id = "Heading1" diff --git a/tests/test-data/strikethrough.docx b/tests/test-data/strikethrough.docx Binary files differnew file mode 100755 index 0000000..0d2b713 --- /dev/null +++ b/tests/test-data/strikethrough.docx |
