We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent da572b0 commit 5a1eda5Copy full SHA for 5a1eda5
html-comments/.gitignore
@@ -0,0 +1 @@
1
+html-comments
html-comments/README.mkd
@@ -0,0 +1,3 @@
+# html-comments
2
+
3
+pull comments out of HTML
html-comments/main.go
@@ -0,0 +1,34 @@
+package main
+import (
4
+ "fmt"
5
+ "os"
6
+ "strings"
7
8
+ "golang.org/x/net/html"
9
+)
10
11
+func main() {
12
13
+ z := html.NewTokenizer(os.Stdin)
14
15
+ for {
16
+ tt := z.Next()
17
+ if tt == html.ErrorToken {
18
+ break
19
+ }
20
21
+ t := z.Token()
22
23
+ if t.Type == html.CommentToken {
24
+ d := strings.Replace(t.Data, "\n", " ", -1)
25
+ d = strings.TrimSpace(d)
26
+ if d == "" {
27
+ continue
28
29
+ fmt.Println(d)
30
31
32
33
34
+}
0 commit comments