summaryrefslogtreecommitdiff
path: root/examples/html.go
diff options
context:
space:
mode:
authorAdam Scarr <adam@vektah.net>2017-08-06 17:02:39 +1000
committerAdam Scarr <adam@vektah.net>2017-08-06 17:02:39 +1000
commita65a9325aaebd1499a8e523463cc023124f8536a (patch)
tree2fb31800b67a3914a7204a28319a7aeb0ac649c7 /examples/html.go
parent8b343d6360d0edc065b9b62ab5e708e907b45a92 (diff)
Get the HTML parser working
Diffstat (limited to 'examples/html.go')
-rw-r--r--examples/html.go34
1 files changed, 0 insertions, 34 deletions
diff --git a/examples/html.go b/examples/html.go
deleted file mode 100644
index d1a290a..0000000
--- a/examples/html.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package main
-
-import (
- "fmt"
-
- . "github.com/vektah/goparsify"
-)
-
-func html(p Pointer) (Node, Pointer) {
- identifier := And(Range("a-z", 1, 1), Range("a-zA-Z0-9"))
- text := CharRunUntil("<>")
-
- var tag Parser
-
- element := Any(text, &tag)
- elements := Kleene(element)
- //attr := And(identifier, equal, String())
- attr := And(identifier, "=", `"test"`)
- attrws := And(attr, WS)
- attrs := Kleene(attrws)
- tstart := And("<", identifier, attrs, ">")
- tend := And("</", identifier, ">")
- tag = And(tstart, elements, tend)
-
- return element(p)
-}
-
-func main() {
- result, _, err := ParseString(html, "<h1>hello world</h1>")
- if err != nil {
- panic(err)
- }
- fmt.Printf("%#v\n", result)
-}