-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken.go
More file actions
80 lines (63 loc) · 1.34 KB
/
token.go
File metadata and controls
80 lines (63 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package whtml
type AttributeType uint32
const (
// attribute="Value"
StringAttribute AttributeType = iota
// attribute={{this.Value}}
MustacheAttribute
// attribute without an equal assign, treated as boolean true
BoolAttribute
// ...{{this.vdomAttrs()}}
VariadicAttribute
)
type Attribute struct {
Type AttributeType
Key, Val string
Pos Pos
Mustaches []string // interpolated mustaches in StringAttribute
}
// Token represents a HTML Token
type Token struct {
Type TokenType
Data string
Attrs []Attribute
Pos Pos
}
// A TokenType is the type of a Token.
type TokenType uint32
const (
// ErrorToken means that an error occurred during tokenization.
ErrorToken TokenType = iota
// EOF
EOFToken
// TextToken means a text node.
TextToken
// Mustache token
MustacheToken
// A StartTagToken looks like <a>.
StartTagToken
// An EndTagToken looks like </a>.
EndTagToken
// A SelfClosingTagToken tag looks like <br/>.
SelfClosingTagToken
// A CommentToken looks like <!--x-->.
CommentToken
)
var voidElements = map[string]bool{
"area": true,
"base": true,
"br": true,
"col": true,
"command": true,
"embed": true,
"hr": true,
"img": true,
"input": true,
"keygen": true,
"link": true,
"meta": true,
"param": true,
"source": true,
"track": true,
"wbr": true,
}