diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-06-08 19:26:10 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-06-08 19:42:40 +0100 |
| commit | 6752668de501328c25d59acdf9a44e25f76ac2ca (patch) | |
| tree | c567a8a452dd70ef5161b7d346fff4a3dd3488a6 /mammoth | |
| parent | 6f9f1c10141d4b6d77a8420ffee7ab39a063fa3c (diff) | |
Support non breaking hyphen elements
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/docx/body_xml.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index a087191..db3da4e 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -1,5 +1,6 @@ import contextlib import re +import sys from .. import documents from .. import results @@ -9,6 +10,9 @@ from .xmlparser import node_types, XmlElement from .styles_xml import Styles from .uris import replace_fragment, uri_to_zip_entry_name +if sys.version_info >= (3, ): + unichr = chr + def reader( numbering=None, @@ -202,6 +206,10 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return _success(documents.tab()) + def no_break_hyphen(element): + return _success(documents.text(unichr(0x2011))) + + def table(element): return _read_xml_elements(element.children) \ .flat_map(calculate_row_spans) \ @@ -432,6 +440,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f "w:fldChar": read_fld_char, "w:instrText": read_instr_text, "w:tab": tab, + "w:noBreakHyphen": no_break_hyphen, "w:tbl": table, "w:tr": table_row, "w:tc": table_cell, |
