// For every <a> in the selection, replace with a MD-style link. // Stuffs the results into the supplied channel. func fetchFormattedResult(l page.Page, results chan<- string) { doc, _ := l.Fetch() answer := doc.Find(".answer") if answer.Nodes == nil { results <- fmt.Sprintf("No answers given for <%s>", l.Url) return } selection := answer.First().Find(".post-text") text := selection.Text() selection.Find("a").Each(func(i int, s *goquery.Selection) { href, _ := s.Attr("href") linkText := s.Text() var mdPage = []string{ "[", linkText, "](", href, ")", } if strings.EqualFold(linkText, href) { mdPage = []string{ "<", linkText, ">", } } text = strings.Replace(text, linkText, strings.Join(mdPage, ""), 1) }) results <- linkHeading(l) + text }