aboutsummaryrefslogtreecommitdiff
path: root/formatter
diff options
context:
space:
mode:
Diffstat (limited to 'formatter')
-rw-r--r--formatter/formatter.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/formatter/formatter.go b/formatter/formatter.go
index f5d7517..8bd1c4d 100644
--- a/formatter/formatter.go
+++ b/formatter/formatter.go
@@ -61,7 +61,7 @@ func printAttrs(attrs []parser.Attr) {
if len(classes) > 0 {
fmt.Print(" class=\"")
for i, a := range classes {
- fmt.Print(a.Value)
+ printAttrVal(a.Value)
if i != len(classes)-1 {
fmt.Print(" ")
} else {
@@ -74,18 +74,22 @@ func printAttrs(attrs []parser.Attr) {
fmt.Printf(" %s", a.Key)
if a.Value != "" {
fmt.Print("=\"")
- for _, r := range a.Value {
- if v, ok := attrValueEscapes[r]; ok {
- fmt.Print(v)
- } else {
- fmt.Printf("%c", r)
- }
- }
+ printAttrVal(a.Value)
fmt.Print("\"")
}
}
}
+func printAttrVal(s string) {
+ for _, r := range s {
+ if v, ok := attrValueEscapes[r]; ok {
+ fmt.Print(v)
+ } else {
+ fmt.Printf("%c", r)
+ }
+ }
+}
+
func printText(s string) {
for _, r := range s {
if v, ok := stringEscapes[r]; ok {