Allow adding custom styles to images

This commit is contained in:
Marc Izquierdo 2023-09-12 14:59:17 +02:00
parent e96880f42b
commit ebebb1b7e9
No known key found for this signature in database
GPG Key ID: D186C82353C9774D

View File

@ -72,6 +72,8 @@ type HtmlRendererParameters struct {
HeaderIDPrefix string HeaderIDPrefix string
// If set, add this text to the back of each Header ID, to ensure uniqueness. // If set, add this text to the back of each Header ID, to ensure uniqueness.
HeaderIDSuffix string HeaderIDSuffix string
// If set, add this style to each image.
ImageStyleTag string
} }
// Html is a type that implements the Renderer interface for HTML output. // Html is a type that implements the Renderer interface for HTML output.
@ -521,6 +523,10 @@ func (options *Html) Image(out *bytes.Buffer, link []byte, title []byte, alt []b
out.WriteString("\" title=\"") out.WriteString("\" title=\"")
attrEscape(out, title) attrEscape(out, title)
} }
if options.parameters.ImageStyleTag != "" {
out.WriteString("\" style=\"")
attrEscape(out, []byte(options.parameters.ImageStyleTag))
}
out.WriteByte('"') out.WriteByte('"')
out.WriteString(options.closeTag) out.WriteString(options.closeTag)