summaryrefslogtreecommitdiff
path: root/htmtl/parsers/inner_html.py
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-01-02 22:12:39 +0200
committerAsko Nõmm <asko@nmm.ee>2025-01-02 22:12:39 +0200
commit61c0b0d134d05c1647fa3356486d209bac87d8f6 (patch)
tree3e21dfc63efb1262b6101733b9d1335ce33414fa /htmtl/parsers/inner_html.py
parent89848de97da23a8c732f54bde15080b09e2bb9d9 (diff)
Implement `GenericValue`, `InnerHtml` and `OuterHtml` parsers.
Diffstat (limited to 'htmtl/parsers/inner_html.py')
-rw-r--r--htmtl/parsers/inner_html.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/htmtl/parsers/inner_html.py b/htmtl/parsers/inner_html.py
new file mode 100644
index 0000000..60e90ca
--- /dev/null
+++ b/htmtl/parsers/inner_html.py
@@ -0,0 +1,16 @@
+from typing import Optional
+
+from dompa import Dompa
+from dompa.nodes import Node
+
+from ..parser import Parser
+
+
+class InnerHtml(Parser):
+ def traverse(self, node: Node) -> Optional[Node]:
+ if "inner-html" in node.attributes:
+ child_nodes = Dompa(self.expression(node.attributes["inner-html"])).nodes()
+ node.children = child_nodes
+ node.attributes.pop("inner-html")
+
+ return node \ No newline at end of file