-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelements.go
More file actions
64 lines (59 loc) · 1.33 KB
/
elements.go
File metadata and controls
64 lines (59 loc) · 1.33 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
package termwind
type Tag string
const (
TagAnchor Tag = "a"
TagBreakLine Tag = "br"
TagDd Tag = "dd"
TagDiv Tag = "div"
TagDl Tag = "dl"
TagDt Tag = "dt"
TagHr Tag = "hr"
TagLi Tag = "li"
TagOl Tag = "ol"
TagParagraph Tag = "p"
TagRaw Tag = "raw"
TagSpan Tag = "span"
TagUl Tag = "ul"
)
type Style struct {
PaddingLeft int
PaddingRight int
PaddingTop int
PaddingBottom int
MarginLeft int
MarginRight int
MarginTop int
MarginBottom int
Bold bool
Italic bool
Underline bool
Strikethrough bool
TextTransform string
ForegroundColor string
BackgroundColor string
Truncate bool
MaxWidth int
MinWidth int
}
// Element represents a single node in the parsed element tree.
// Tag identifies the HTML element type, Style holds the resolved
// visual properties, and Children contains nested elements.
type Element struct {
Tag Tag
Classes []string
Attrs map[string]string
Style Style
Children []*Element
Content string
Parent *Element
}
// IsInline reports whether a tag is an inline-level element.
// Inline elements do not support vertical margins.
func (t Tag) IsInline() bool {
switch t {
case TagSpan, TagAnchor:
return true
default:
return false
}
}