diff options
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/documents.py | 6 | ||||
| -rw-r--r-- | mammoth/docx/document_xml.py | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/mammoth/documents.py b/mammoth/documents.py index 4438b06..703e436 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -3,7 +3,7 @@ import dodge Document = dodge.data_class("Document", ["children"]) Paragraph = dodge.data_class("Paragraph", ["children", "style_id", "style_name", "numbering"]) -Run = dodge.data_class("Run", ["children", "style_id", "is_bold", "is_italic"]) +Run = dodge.data_class("Run", ["children", "style_id", "style_name", "is_bold", "is_italic"]) Text = dodge.data_class("Text", ["value"]) Hyperlink = dodge.data_class("Hyperlink", ["href", "children"]) @@ -23,8 +23,8 @@ document = Document 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, is_bold=None, is_italic=None): - return Run(children, style_id, bool(is_bold), bool(is_italic)) +def run(children, style_id=None, style_name=None, is_bold=None, is_italic=None): + return Run(children, style_id, style_name, bool(is_bold), bool(is_italic)) text = Text diff --git a/mammoth/docx/document_xml.py b/mammoth/docx/document_xml.py index 83d82df..247bcbc 100644 --- a/mammoth/docx/document_xml.py +++ b/mammoth/docx/document_xml.py @@ -51,6 +51,12 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file): style_id = properties \ .find_child_or_null("w:rStyle") \ .attributes.get("w:val") + + if style_id is None: + style_name = None + else: + style_name = styles.find_character_style_by_id(style_id).name + is_bold = properties.find_child("w:b") is_italic = properties.find_child("w:i") @@ -58,6 +64,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file): .map(lambda children: documents.run( children=children, style_id=style_id, + style_name=style_name, is_bold=is_bold, is_italic=is_italic, )) |
