From f2db2bcf40c2c497a33b1f087b67111c3351a406 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 12:24:07 +0100 Subject: Read optional attributes of comments --- mammoth/docx/comments_xml.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mammoth') diff --git a/mammoth/docx/comments_xml.py b/mammoth/docx/comments_xml.py index fbf1bc4..6d35c12 100644 --- a/mammoth/docx/comments_xml.py +++ b/mammoth/docx/comments_xml.py @@ -10,12 +10,15 @@ def create_comments_reader(body_reader): def _read_comment_element(element): + def read_optional_attribute(name): + return element.attributes.get(name, "").strip() or None + return body_reader.read_all(element.children).map(lambda body: documents.comment( comment_id=element.attributes["w:id"], body=body, - author_name=None, - author_initials=None, + author_name=read_optional_attribute("w:author"), + author_initials=read_optional_attribute("w:initials"), )) return read_comments_xml_element -- cgit v1.2.3