Skip to content

Commit

Permalink
make SetAttributeString() accept both []byte and string
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Apr 2, 2024
1 parent ce6424a commit e405d57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion renderer/html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,14 @@ func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)
_, _ = w.Write(attr.Name)
_, _ = w.WriteString(`="`)
// TODO: convert numeric values to strings
_, _ = w.Write(util.EscapeHTML(attr.Value.([]byte)))
var value []byte
switch typed := attr.Value.(type) {
case []byte:
value = typed
case string:
value = util.StringToReadOnlyBytes(typed)
}
_, _ = w.Write(util.EscapeHTML(value))
_ = w.WriteByte('"')
}
}
Expand Down

0 comments on commit e405d57

Please sign in to comment.