From 519dfddb18eea15c26d0d8d8da68e1cebd865c39 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 11 Feb 2015 20:27:25 +0000 Subject: Read bookmarks --- mammoth/documents.py | 2 ++ mammoth/docx/document_xml.py | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'mammoth') diff --git a/mammoth/documents.py b/mammoth/documents.py index 9028b03..0e96c05 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -58,6 +58,8 @@ image = Image def hyperlink(children, href=None, anchor=None): return Hyperlink(href, anchor, children) + +bookmark = Bookmark = dodge.data_class("Bookmark", ["name"]) table = Table diff --git a/mammoth/docx/document_xml.py b/mammoth/docx/document_xml.py index 56298f3..8bfdd6f 100644 --- a/mammoth/docx/document_xml.py +++ b/mammoth/docx/document_xml.py @@ -186,6 +186,15 @@ def _create_reader(numbering, content_types, relationships, styles, note_element else: return children_result + @handler("w:bookmarkStart") + def bookmark_start(element): + name = element.attributes.get("w:name") + if name == "_GoBack": + return results.success(None) + else: + return results.success(documents.bookmark(name)) + + @handler("w:br") def br(element): break_type = element.attributes.get("w:type") -- cgit v1.2.3