From 7a3f2928defb16fc0f16add6f59f2bab7da5bc04 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Sun, 26 May 2024 01:18:44 +0100 Subject: [PATCH] fix: update the StripHTMLTags function - Do not add an extra space between text tokens. - Add a line break if the 'br' tag is detected. --- internal/utilities/utilities.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index b252dde..d3fc812 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -43,7 +43,13 @@ func StripHTMLTags(text string) string { case html.ErrorToken: return builder.String() case html.TextToken: - builder.WriteString(token.Token().Data + " ") + text := token.Token().String() + builder.WriteString(text) + case html.StartTagToken: + tag := token.Token().String() + if tag == "
" { + builder.WriteString("\n") + } } } }