diff options
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/documents.py | 6 | ||||
| -rw-r--r-- | mammoth/docx/document_xml.py | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/mammoth/documents.py b/mammoth/documents.py index 215df8e..03975b2 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -2,7 +2,7 @@ import collections Document = collections.namedtuple("Document", ["children"]) Paragraph = collections.namedtuple("Paragraph", ["children", "style_name", "numbering"]) -Run = collections.namedtuple("Run", ["children", "style_name"]) +Run = collections.namedtuple("Run", ["children", "style_name", "is_bold"]) Text = collections.namedtuple("Text", ["value"]) @@ -11,7 +11,7 @@ document = Document def paragraph(children, style_name=None, numbering=None): return Paragraph(children, style_name, numbering) -def run(children, style_name=None): - return Run(children, style_name) +def run(children, style_name=None, is_bold=None): + return Run(children, style_name, bool(is_bold)) text = Text diff --git a/mammoth/docx/document_xml.py b/mammoth/docx/document_xml.py index c3fb1b7..6488a25 100644 --- a/mammoth/docx/document_xml.py +++ b/mammoth/docx/document_xml.py @@ -26,7 +26,13 @@ def _create_reader(numbering): style_name = properties \ .find_child_or_null("w:rStyle") \ .attributes.get("w:val") - return documents.run(_read_xml_elements(element.children), style_name) + is_bold = properties.find_child("w:b") + + return documents.run( + children=_read_xml_elements(element.children), + style_name=style_name, + is_bold=is_bold, + ) @handler("w:p") |
