Remove blank lines

This commit is contained in:
bel
2019-12-29 11:18:26 -07:00
parent 37408af647
commit 98adb53caf
2 changed files with 39 additions and 0 deletions

View File

@@ -63,6 +63,8 @@ func newItem(i *gofeed.Item, contentFilter, copyright string) (*Item, error) {
item.Content = fmt.Sprintf(`<a href="%s">%s</a><br>%s`, item.Link, item.Title, item.Content)
item.Content = clearBlankLines(item.Content)
return item, nil
}
@@ -109,3 +111,10 @@ func (is Items) Swap(i, j int) {
is[i] = is[j]
is[j] = k
}
func clearBlankLines(s string) string {
r := regexp.MustCompile(`(?m)^\s*<br>\s*$`)
s = r.ReplaceAllLiteralString(s, "")
r = regexp.MustCompile(`(?m)\s\s*`)
return r.ReplaceAllLiteralString(s, "\n")
}