From 8dce33362f5338953ed2a614e736c197e36b9984 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 12:31:50 +0100 Subject: Read comment references --- mammoth/conversion.py | 3 +++ mammoth/documents.py | 6 ++++++ mammoth/docx/body_xml.py | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'mammoth') diff --git a/mammoth/conversion.py b/mammoth/conversion.py index e05cccc..2262392 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -201,6 +201,9 @@ class _DocumentConverter(documents.ElementVisitor): self._html_generator.append(note_generator) self._html_generator.end() + def visit_comment_reference(self, reference): + return [] + def _visit_all(self, elements): return lists.flat_map(self.visit, elements) diff --git a/mammoth/documents.py b/mammoth/documents.py index 93b080c..5d9830e 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -182,4 +182,10 @@ class Comment(object): comment = Comment +@cobble.data +class CommentReference(Element): + comment_id = cobble.field() + +comment_reference = CommentReference + ElementVisitor = cobble.visitor(Element) diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py index c493c4b..fe75f7c 100644 --- a/mammoth/docx/body_xml.py +++ b/mammoth/docx/body_xml.py @@ -334,6 +334,9 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f return note_reference + def read_comment_reference(element): + return _success(documents.comment_reference(element.attributes["w:id"])) + def alternate_content(element): return read_child_elements(element.find_child("mc:Fallback")) @@ -364,6 +367,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f "v:imagedata": read_imagedata, "w:footnoteReference": note_reference_reader("footnote"), "w:endnoteReference": note_reference_reader("endnote"), + "w:commentReference": read_comment_reference, "mc:AlternateContent": alternate_content, "w:sdt": read_sdt } -- cgit v1.2.3