diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-29 22:23:49 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-29 22:23:49 +0000 |
| commit | f49ef5f80a0d20bebd5155f7d8f99b5e6366e35f (patch) | |
| tree | 68c18f3ec1f84e31d5ebeab596c3edce6030ff34 /mammoth/html/nodes.py | |
| parent | 2f8bd9edc77b8508203e221ad96c79f516205d92 (diff) | |
Introduce tag object for HTML elements
Diffstat (limited to 'mammoth/html/nodes.py')
| -rw-r--r-- | mammoth/html/nodes.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/mammoth/html/nodes.py b/mammoth/html/nodes.py index 3b961f2..ff31c8c 100644 --- a/mammoth/html/nodes.py +++ b/mammoth/html/nodes.py @@ -11,10 +11,9 @@ class TextNode(Node): @cobble.data -class Element(Node): +class Tag(object): tag_names = cobble.field() attributes = cobble.field() - children = cobble.field() collapsible = cobble.field() separator = cobble.field() @@ -24,6 +23,32 @@ class Element(Node): @cobble.data +class Element(Node): + tag = cobble.field() + children = cobble.field() + + @property + def tag_name(self): + return self.tag.tag_name + + @property + def tag_names(self): + return self.tag.tag_names + + @property + def attributes(self): + return self.tag.attributes + + @property + def collapsible(self): + return self.tag.collapsible + + @property + def separator(self): + return self.tag.separator + + +@cobble.data class SelfClosingElement(Node): tag_name = cobble.field() attributes = cobble.field() |
