diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-09 10:49:49 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-09-13 13:36:50 +0100 |
| commit | 9bb4538fa9e2390bb52a4db4ba56f0e4772d94c9 (patch) | |
| tree | 31aed9695126d19938cfae22bb1fcacffbe23505 /mammoth/documents.py | |
| parent | a2f856d6703008dcad2537c6ef557fba5f088948 (diff) | |
Use visitor when converting to HTML
Diffstat (limited to 'mammoth/documents.py')
| -rw-r--r-- | mammoth/documents.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/mammoth/documents.py b/mammoth/documents.py index 0fe8d43..d837556 100644 --- a/mammoth/documents.py +++ b/mammoth/documents.py @@ -1,7 +1,11 @@ import cobble -class HasChildren(object): +class Element(object): + pass + + +class HasChildren(Element): children = cobble.field() @@ -26,7 +30,7 @@ class Run(HasChildren): vertical_alignment = cobble.field() @cobble.data -class Text(object): +class Text(Element): value = cobble.field() @cobble.data @@ -47,15 +51,16 @@ class TableCell(HasChildren): pass @cobble.data -class LineBreak(object): +class LineBreak(Element): pass @cobble.data -class Tab(object): +class Tab(Element): pass -class Image(object): +@cobble.visitable +class Image(Element): def __init__(self, alt_text, content_type, open): self.alt_text = alt_text self.content_type = content_type @@ -98,7 +103,7 @@ def hyperlink(children, href=None, anchor=None): @cobble.data -class Bookmark(object): +class Bookmark(Element): name = cobble.field() bookmark = Bookmark @@ -118,7 +123,7 @@ class _NumberingLevel(object): is_ordered = cobble.field() @cobble.data -class Note(object): +class Note(Element): note_type = cobble.field() note_id = cobble.field() body = cobble.field() @@ -153,8 +158,11 @@ def _note_key(note): return (note.note_type, note.note_id) @cobble.data -class NoteReference(object): +class NoteReference(Element): note_type = cobble.field() note_id = cobble.field() note_reference = NoteReference + + +ElementVisitor = cobble.visitor(Element) |
