-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoid-tags.go
More file actions
61 lines (55 loc) · 1.28 KB
/
void-tags.go
File metadata and controls
61 lines (55 loc) · 1.28 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
package GoHtml
/*
A void element is an element in HTML that cannot have any child nodes (i.e., nested elements or text nodes). Void elements only have a start tag; end tags must not be specified for void elements.
*/
import (
"strings"
)
//Void tags
const (
Area string = "area"
Base string = "base"
Br string = "br"
Col string = "col"
Embed string = "embed"
Hr string = "hr"
Img string = "img"
Input string = "input"
Link string = "link"
Meta string = "meta"
Param string = "param"
Source string = "source"
Track string = "track"
Wbr string = "wbr"
)
var (
voidTags = map[string]bool{
"area": true,
"base": true,
"br": true,
"col": true,
"embed": true,
"hr": true,
"img": true,
"input": true,
"link": true,
"meta": true,
"param": true,
"source": true,
"track": true,
"wbr": true,
"!doctype": true,
}
)
// IsVoidTag returns whether the tagName is a void tag or DTD
func IsVoidTag(tagName string) bool {
tagName = strings.TrimSpace(strings.ToLower(tagName))
return voidTags[tagName]
}
/*
A DTD defines the structure and the legal elements and attributes of an XML document.
*/
const (
//This is not a void el. but added it anyway.
DOCTYPEDTD string = "!DOCTYPE"
)