From c111da9c8cc76ad04e32e6a84946f648f2f9a799 Mon Sep 17 00:00:00 2001 From: mdosch Date: Sun, 26 May 2019 23:53:18 +0200 Subject: [PATCH] Made some feeds look less bloated by finally removing double line breaks. --- getarticles.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/getarticles.go b/getarticles.go index 8460603..e7a9b5a 100644 --- a/getarticles.go +++ b/getarticles.go @@ -221,15 +221,18 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) { } } - // To make the message look not so bloated we remove multiple newlines. - // Split the article description/content into fragments between newlines. - fragments := strings.Split(description, "\n") + // Remove lines only consisting of "> "; thank you reddit. + description = strings.Replace(description, "> \n", "", -1) + + // To make the message look not so bloated we remove double newlines. + // Split the article description/content into fragments between double newlines. + fragments := strings.Split(description, "\n\n") // Empty article description/content description = "" // Fill article description/content with the fragments separated by one newline. for _, line := range fragments { - // Only if the only content is not "> ", thank you reddit. - if line != "> " { + // Only if the only content is not empty. + if line != "" { description = description + line + "\n" } }