diff --git a/getarticles.go b/getarticles.go index abbed7e..e8329c2 100644 --- a/getarticles.go +++ b/getarticles.go @@ -203,10 +203,22 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) { output = output + feed.Title + ": *" + article.Title + "*\n" + cleanURL } else { - // Strip HTML as we want to get plain text. - description, err := html2text.FromString(article.Description) - if err != nil { - return "", err + var description string + + // Some feeds don't provide a description, let's use the content + // in this case, otherwise use the shorter description. + if article.Description != "" { + // Strip HTML as we want to get plain text. + description, err = html2text.FromString(article.Description) + if err != nil { + return "", err + } + } else { + // Strip HTML as we want to get plain text. + description, err = html2text.FromString(article.Content) + if err != nil { + return "", err + } } // To make the message look not so bloated we remove multiple newlines. @@ -216,7 +228,12 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) { description = "" // Fill article description/content with the fragments separated by one newline. for _, line := range fragments { - description = description + line + "\n" + l := len(line) + println("Fragment: ", line, l) + // Only if the only content is not "> ", thank you reddit. + if line != "> " { + description = description + line + "\n" + } } // Only append article link if it is not yet contained in description (e.g. read more: URL).