aboutsummaryrefslogtreecommitdiff
path: root/src/html.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.nim')
-rw-r--r--src/html.nim30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/html.nim b/src/html.nim
new file mode 100644
index 0000000..4ae5ee1
--- /dev/null
+++ b/src/html.nim
@@ -0,0 +1,30 @@
+type Html = object
+ tags: seq[string]
+
+type Tag {.acyclic.} = object
+ name: string
+ text: string
+ nested: seq[Tag]
+
+func parseHTML(html: string): Html = discard
+
+# Todo: revamp parsing: keep track of tags, entities, etc
+proc renderHTML*(html: string) =
+ var
+ in_angle = false
+ in_body = false
+
+ # _Why_ is it i, c and not c, i...
+ for i, c in html:
+ if c == '<':
+ in_angle = true
+ if html[i..i+4] == "<body":
+ in_body = true
+ elif c == '>':
+ in_angle = false
+ elif not in_angle and in_body and c in {char(32)..char(126), '\n'}:
+ stdout.write(c)
+
+proc renderSource*(html: string) =
+ for i, c in html:
+ stdout.write(c)