package main import ( "fmt" "sort" htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2" "github.com/charmbracelet/glamour" goFeed "github.com/mmcdole/gofeed" ) var glamourStyle = glamour.WithStylePath("./catppuccin.glamour.json") type Options struct { sortAsc bool showDesc bool } func getFeed(url string) goFeed.Feed { fp := goFeed.NewParser() feed, _ := fp.ParseURL(url) sort.Sort(feed) return *feed } func renderFeedItem(item *goFeed.Item, showDesc bool) string { itemString := fmt.Sprintf("%s%s %s\n", style.date.Render(item.PublishedParsed.Format("02.01.2006 15:04")), style.author.Render(item.Author.Name), style.title.Render(item.Title), ) if showDesc { contentMd, _ := htmltomarkdown.ConvertString(item.Description) glamourRender, _ := glamour.NewTermRenderer( glamour.WithAutoStyle(), glamourStyle, ) content, _ := glamourRender.Render(contentMd) itemString = fmt.Sprintf("%s%s\n", itemString, content) } return itemString }