mirror of
https://github.com/miniflux/v2.git
synced 2025-07-17 17:08:36 +00:00
feat(sanitizer): improve text truncation with better space handling
This commit is contained in:
parent
e777f12490
commit
f2f60a8f73
2 changed files with 53 additions and 2 deletions
|
@ -9,8 +9,9 @@ func TruncateHTML(input string, max int) string {
|
|||
text := StripTags(input)
|
||||
text = strings.ReplaceAll(text, "\n", " ")
|
||||
text = strings.ReplaceAll(text, "\t", " ")
|
||||
text = strings.ReplaceAll(text, " ", " ")
|
||||
text = strings.TrimSpace(text)
|
||||
|
||||
// Collapse multiple spaces into a single space
|
||||
text = strings.Join(strings.Fields(text), " ")
|
||||
|
||||
// Convert to runes to be safe with unicode
|
||||
runes := []rune(text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue