diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-11-03 16:00:19 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-11-03 16:00:19 +0000 |
| commit | cd95535a1bb0f486d4a102cfc622ae5228c3071d (patch) | |
| tree | 3d4221b5b7f34a54a0f302032738bc8583d5428c /mammoth | |
| parent | bde57149ea716c394c88d8d94ce764d5cd8670c4 (diff) | |
Read table styles
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/docx/body_xml.py | 2 | ||||
| -rw-r--r-- | mammoth/docx/styles_xml.py | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index 12951c9..6577522 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -24,7 +24,7 @@ def reader( ): if styles is None: - styles = Styles({}, {}) + styles = Styles.EMPTY read_all = _create_reader( numbering=numbering, diff --git a/mammoth/docx/styles_xml.py b/mammoth/docx/styles_xml.py index 1166f11..3339bb6 100644 --- a/mammoth/docx/styles_xml.py +++ b/mammoth/docx/styles_xml.py @@ -2,23 +2,36 @@ import collections class Styles(object): - def __init__(self, paragraph_styles, character_styles): + def __init__(self, paragraph_styles, character_styles, table_styles): self._paragraph_styles = paragraph_styles self._character_styles = character_styles + self._table_styles = table_styles def find_paragraph_style_by_id(self, style_id): return self._paragraph_styles.get(style_id) def find_character_style_by_id(self, style_id): return self._character_styles.get(style_id) + + def find_table_style_by_id(self, style_id): + return self._table_styles.get(style_id) + + +Styles.EMPTY = Styles( + paragraph_styles={}, + character_styles={}, + table_styles={}, +) def read_styles_xml_element(element): paragraph_styles = {} character_styles = {} + table_styles = {} styles = { "paragraph": paragraph_styles, "character": character_styles, + "table": table_styles, } for style_element in element.find_children("w:style"): @@ -28,7 +41,11 @@ def read_styles_xml_element(element): if style_set is not None: style_set[style.style_id] = style - return Styles(paragraph_styles, character_styles) + return Styles( + paragraph_styles=paragraph_styles, + character_styles=character_styles, + table_styles=table_styles, + ) def _read_style_element(element): |
