From b77d75f05fb2059389c05f6c01484e0cd12e796e Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Wed, 24 Dec 2025 13:50:07 +0530 Subject: feat: introduce email folder synchronization and management, refactor email services, and update UI styles --- utils/format/html.go | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 utils/format/html.go (limited to 'utils/format/html.go') diff --git a/utils/format/html.go b/utils/format/html.go new file mode 100644 index 0000000..36e2425 --- /dev/null +++ b/utils/format/html.go @@ -0,0 +1,73 @@ +package format + +import ( + "regexp" + "strings" +) + +func GenerateSnippet(bodyText, bodyHTML string) string { + text := bodyText + if text == "" && bodyHTML != "" { + text = StripHTML(bodyHTML) + } + + text = strings.TrimSpace(text) + if len(text) > 150 { + text = text[:150] + "..." + } + + return text +} + +func StripHTML(html string) string { + text := html + + styleRegex := regexp.MustCompile(`(?i)`) + text = styleRegex.ReplaceAllString(text, "") + + scriptRegex := regexp.MustCompile(`(?i)`) + text = scriptRegex.ReplaceAllString(text, "") + + headRegex := regexp.MustCompile(`(?i)
]*>[\s\S]*?`) + text = headRegex.ReplaceAllString(text, "") + + text = strings.ReplaceAll(text, "