mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
make SetAttributeString() accept both []byte and string
This commit is contained in:
parent
ce6424aa0e
commit
e405d57be0
1 changed files with 8 additions and 1 deletions
|
|
@ -786,7 +786,14 @@ func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)
|
||||||
_, _ = w.Write(attr.Name)
|
_, _ = w.Write(attr.Name)
|
||||||
_, _ = w.WriteString(`="`)
|
_, _ = w.WriteString(`="`)
|
||||||
// TODO: convert numeric values to strings
|
// 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('"')
|
_ = w.WriteByte('"')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue