package mailhtml import ( "fmt" "sort" "strings" "golang.org/x/net/html" "golang.org/x/net/html/atom" ) // Finding is one thing mail clients will do to a body that its author did not // ask for. Code is stable and machine-readable; Message is what the editor // shows. type Finding struct { Code string `json:"code"` Severity string `json:"severity"` // error | warning | info Message string `json:"message"` } const ( SeverityError = "error" SeverityWarning = "warning" SeverityInfo = "info" ) // Gmail truncates a message past this many bytes and hides the rest behind a // "View entire message" link, which also hides the unsubscribe footer and // stops the open pixel firing for anyone who does not expand it. const gmailClipBytes = 102 * 1024 // CSS the Word rendering engine behind Outlook 2016-2021 on Windows ignores // outright. Every one of these silently collapses a layout there. var wordUnsupportedProps = map[string]bool{ "position": true, "float": true, "transform": true, "animation": true, "transition": true, "box-shadow": true, "text-shadow": true, "background-size": true, "object-fit": true, "flex": true, "gap": true, } // Elements no mail client renders. Each is also a spam signal in its own // right, which matters more for cold outreach than for marketing mail. var strippedElements = map[atom.Atom]string{ atom.Script: "