package main import ( "bufio" "context" "fmt" "log" "os" "sort" "strings" "time" "github.com/mmcdole/gofeed" "golang.org/x/net/html" ) type RSSInfo struct { Items []gofeed.Item } // Len returns the length of Items. func (f RSSInfo) Len() int { return len(f.Items) } // Less compares PublishedParsed of Items[i], Items[k] // and returns true if Items[i] is less than Items[k]. func (f RSSInfo) Less(i, k int) bool { return f.Items[k].PublishedParsed.Before( *f.Items[i].PublishedParsed, ) } // Swap swaps Items[i] and Items[k]. func (f RSSInfo) Swap(i, k int) { f.Items[i], f.Items[k] = f.Items[k], f.Items[i] } func main() { ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) defer cancel() fmt.Println("") fmt.Println("") fmt.Println("") fmt.Println("") fmt.Println("") fmt.Println("") } func fixHtml(rawHtml string) string { content := "" // Parse the HTML string doc, err := html.Parse(strings.NewReader(rawHtml)) if err != nil { content = rawHtml } else { // Modify img and video elements to have static height and width var f func(*html.Node) f = func(n *html.Node) { switch n.Data { case "img", "video", "iframe", "object", "embed", "canvas": n.Attr = append(n.Attr, html.Attribute{Key: "height", Val: "400px"}) // n.Attr = append(n.Attr, html.Attribute{Key: "width", Val: "100px"}) } for c := n.FirstChild; c != nil; c = c.NextSibling { f(c) } } f(doc) // Convert the modified doc back to a string buf := &strings.Builder{} err = html.Render(buf, doc) if err != nil { log.Println(err) } else { content = buf.String() } } return content }