aboutsummaryrefslogtreecommitdiff
path: root/mammoth/html/nodes.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-14 08:10:01 +0000
committerMichael Williamson <mike@zwobble.org>2016-03-14 20:09:13 +0000
commit00cfd0d5bae2e7688754dfc458016d42abfcd037 (patch)
tree24b49bdad94d9c34c755ec50e0db5fb39a34aee8 /mammoth/html/nodes.py
parent2329dbcbbc945437256569c789b127e454069c98 (diff)
Add HTML AST with strip_empty function
Diffstat (limited to 'mammoth/html/nodes.py')
-rw-r--r--mammoth/html/nodes.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/mammoth/html/nodes.py b/mammoth/html/nodes.py
new file mode 100644
index 0000000..aae4888
--- /dev/null
+++ b/mammoth/html/nodes.py
@@ -0,0 +1,32 @@
+import cobble
+
+
+class Node(object):
+ pass
+
+
+@cobble.data
+class TextNode(Node):
+ value = cobble.field()
+
+
+@cobble.data
+class Element(Node):
+ tag_names = cobble.field()
+ attributes = cobble.field()
+ children = cobble.field()
+ collapsible = cobble.field()
+
+
+@cobble.data
+class SelfClosingElement(Node):
+ tag_name = cobble.field()
+ attributes = cobble.field()
+
+
+@cobble.visitable
+class ForceWrite(Node):
+ pass
+
+
+NodeVisitor = cobble.visitor(Node)