-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
43 lines (39 loc) · 903 Bytes
/
debug.go
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
package csshtml
import (
"fmt"
"strings"
)
func indent(s string) string {
ret := []string{}
for _, line := range strings.Split(s, "\n") {
ret = append(ret, " "+line)
}
return strings.Join(ret, "\n")
}
func (b sBlock) String() string {
ret := []string{}
var firstline string
if b.name != "" {
firstline = fmt.Sprintf("@%s ", b.name)
}
firstline = firstline + b.componentValues.String() + " {"
ret = append(ret, firstline)
for _, v := range b.rules {
ret = append(ret, " "+v.key.String()+":"+v.value.String()+";")
}
for _, v := range b.childAtRules {
ret = append(ret, indent(v.String()))
}
for _, v := range b.blocks {
ret = append(ret, indent(v.String()))
}
ret = append(ret, "}")
return strings.Join(ret, "\n")
}
func (t tokenstream) String() string {
ret := []string{}
for _, tok := range t {
ret = append(ret, tok.Value)
}
return strings.Join(ret, "")
}