diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-09-27 17:21:48 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-09-27 17:21:48 +0100 |
| commit | 9fb300452f2e1734e531abde614b8513d0edd093 (patch) | |
| tree | 380df590deb0efee43ae902107d47716d761033b /mammoth/documents.py | |
| parent | c8bfc778472b644d56a5694553bec8621159c4ce (diff) | |
Read vertical alignment from document.xml
Diffstat (limited to 'mammoth/documents.py')
| -rw-r--r-- | mammoth/documents.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/mammoth/documents.py b/mammoth/documents.py index 49b2396..e7a46c4 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -3,7 +3,10 @@ import dodge Document = dodge.data_class("Document", ["children", "footnotes"]) Paragraph = dodge.data_class("Paragraph", ["children", "style_id", "style_name", "numbering"]) -Run = dodge.data_class("Run", ["children", "style_id", "style_name", "is_bold", "is_italic", "is_underline"]) +Run = dodge.data_class("Run", [ + "children", "style_id", "style_name", "is_bold", "is_italic", + "is_underline", "vertical_alignment", +]) Text = dodge.data_class("Text", ["value"]) Hyperlink = dodge.data_class("Hyperlink", ["href", "children"]) Table = dodge.data_class("Table", ["children"]) @@ -30,8 +33,18 @@ def document(children, footnotes=None): def paragraph(children, style_id=None, style_name=None, numbering=None): return Paragraph(children, style_id, style_name, numbering) -def run(children, style_id=None, style_name=None, is_bold=None, is_italic=None, is_underline=None): - return Run(children, style_id, style_name, bool(is_bold), bool(is_italic), bool(is_underline)) +def run(children, style_id=None, style_name=None, is_bold=None, is_italic=None, is_underline=None, vertical_alignment=None): + if vertical_alignment is None: + vertical_alignment = VerticalAlignment.baseline + return Run( + children, style_id, style_name, bool(is_bold), bool(is_italic), + bool(is_underline), vertical_alignment, + ) + +class VerticalAlignment(object): + baseline = "baseline" + superscript = "superscript" + subscript = "subscript" text = Text |
