package render import ( "strings" "github.com/jaytaylor/html2text" ) // HTMLToText converts an HTML document to readable plain text. Links keep // their target in brackets after the link text. On a parse failure the // input is returned with tags left alone. func HTMLToText(s string) string { out, err := html2text.FromString(s, html2text.Options{}) if err != nil { return strings.TrimSpace(s) } return strings.TrimSpace(out) }