diff --git a/view/html.go b/view/html.go index 491b6c883a916b5f13dea963d07e184580695223..76ff2157ab30131ad6605ee06986c8f1cfaea483 100644 --- a/view/html.go +++ b/view/html.go @@ -83,6 +83,20 @@ func ProcessBody(rawBody string) (string, error) { s.ReplaceWithHtml(hyperlink(href, s.Text())) }) + // Format images into terminal hyperlinks + doc.Find("img").Each(func(i int, s *goquery.Selection) { + src, exists := s.Attr("src") + if !exists { + return + } + alt, _ := s.Attr("alt") + + if alt == "" { + alt = "Does not contain alt text" + } + s.ReplaceWithHtml(hyperlink(src, fmt.Sprintf("\n [Click here to view image: %s] \n", alt))) + }) + // Get the document's text content, which now includes our formatting text := doc.Text()