aboutsummaryrefslogtreecommitdiff
path: root/grammars/html.bpeg
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-09-12 18:20:13 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-09-12 18:20:13 -0700
commitc18eb4c9968289c4808d70f7124c0b6bed5eb022 (patch)
tree97fdbee687e2e83f83403161365b90c99c102ee6 /grammars/html.bpeg
parentc0125378b9ec96149aed3107bff719cd8a01b16d (diff)
Added backrefs
Diffstat (limited to 'grammars/html.bpeg')
-rw-r--r--grammars/html.bpeg18
1 files changed, 18 insertions, 0 deletions
diff --git a/grammars/html.bpeg b/grammars/html.bpeg
new file mode 100644
index 0000000..f6812bd
--- /dev/null
+++ b/grammars/html.bpeg
@@ -0,0 +1,18 @@
+# HTML grammar
+HTML = __ ?(doctype __) *html-element%__ __;
+
+doctype = "<!DOCTYPE" &`>;
+
+html-element = void-element / template-element / raw-text-element / normal-element;
+
+void-element = `< ("area"/"base"/"br"/"col"/"embed"/"hr"/"img"/"input"/"link"/"meta"/"param"/"source"/"track"/"wbr") *(__attribute) __ ?`/ __ `>;
+
+template-element = "<template" __`> __ *(~~`< / comment / html-element / ~~("</template"__`>)) ("</template"__`>);
+
+raw-text-element = `<@[tag]("script"/"style"/"textarea"/"title") *(__attribute) __ `> &("</"tag__`>);
+
+normal-element = !raw-text-element `<@[tag]id *(__attribute) __ `> *(~~`< / comment / html-element / ~~("</"tag__`>)) "</"tag__`>;
+
+comment = "<!--" &&"-->";
+
+attribute = +id%`:__`=__(id / `" &`" / `' &`');