package classes import ( "bytes" "strings" xhtml "golang.org/x/net/html" ) // ConvertH1 turns every h1 element of html into an h2 and returns the // result with the number of headings it converted. It works on the // x/net/html tokenizer's raw tokens: only the tag name of an h1 start, end // or self-closing tag changes, and every other byte (attributes, text, // comments, the content of script or style) is copied as it is. Text that // merely looks like a tag inside raw-text elements or comments is not a // tag and is not touched. html without an h1 comes back unchanged with 0. func ConvertH1(html string) (string, int) { if !containsFold(html, "= 3 { b.WriteString("= 4 { b.WriteString("