package classes import ( "bytes" "strings" xhtml "golang.org/x/net/html" ) // SetImageAlt sets the alt attribute of every img in html whose src // attribute (unescaped) equals src, adding it when missing. It returns the // new HTML, the number of matching images and the alt the first match had // (nil when it had none). It works on the x/net/html tokenizer: a matching // img tag is written again from its token, so every attribute value, // alt included, is escaped by the tokenizer and never concatenated; every // other byte of html is copied as it is. An empty alt marks a decorative // image (alt=""). func SetImageAlt(html, src, alt string) (string, int, *string) { if src == "" || !containsFold(html, "