Skip to content

Commit

Permalink
Merge pull request #448 from movsb/fix-attribute-string
Browse files Browse the repository at this point in the history
make RenderAttributes() accept both []byte and string
  • Loading branch information
yuin committed Apr 3, 2024
2 parents ce6424a + e405d57 commit c15e394
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 c15e394

Please sign in to comment.