aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-08-15 12:38:25 +0100
committerMichael Williamson <mike@zwobble.org>2020-08-15 12:38:25 +0100
commit6c4474fe42f489f7f87361e4633060791b6eeb89 (patch)
treebffdd476256c890f054494570cce2b9ec02c321e
parenta352b5250e295e0fea9b5cc94d2f44194b8bdf72 (diff)
Support soft hyphens
-rw-r--r--NEWS1
-rw-r--r--mammoth/docx/body_xml.py5
-rw-r--r--tests/docx/body_xml_tests.py7
3 files changed, 13 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d549748..caa81ba 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
# 1.4.11
* Read font size for runs.
+* Support soft hyphens.
# 1.4.10
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index e65c5b2..f0aab84 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -230,6 +230,10 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
return _success(documents.text(unichr(0x2011)))
+ def soft_hyphen(element):
+ return _success(documents.text(u"\u00ad"))
+
+
def table(element):
properties = element.find_child_or_null("w:tblPr")
return _ReadResult.map_results(
@@ -475,6 +479,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
"w:instrText": read_instr_text,
"w:tab": tab,
"w:noBreakHyphen": no_break_hyphen,
+ "w:softHyphen": soft_hyphen,
"w:tbl": table,
"w:tr": table_row,
"w:tc": table_cell,
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py
index 17d631d..c9863bf 100644
--- a/tests/docx/body_xml_tests.py
+++ b/tests/docx/body_xml_tests.py
@@ -539,6 +539,13 @@ def no_break_hyphen_element_is_read_as_non_breaking_hyphen_character():
@istest
+def soft_hyphen_element_is_read_as_soft_hyphen_character():
+ element = xml_element("w:softHyphen")
+ tab = _read_and_get_document_xml_element(element)
+ assert_equal(documents.text(u"\u00ad"), tab)
+
+
+@istest
class TableTests(object):
@istest
def word_table_is_read_as_document_table_element(self):