[ok]handle tag
(doc *goquery.Document)
| 277 | |
| 278 | //[ok]handle tag <img/> |
| 279 | func handleImg(doc *goquery.Document) *goquery.Document { |
| 280 | doc.Find("img").Each(func(i int, selection *goquery.Selection) { |
| 281 | if src, ok := selection.Attr("src"); ok { |
| 282 | alt := "" |
| 283 | if val, ok := selection.Attr("alt"); ok { |
| 284 | alt = val |
| 285 | } |
| 286 | md := fmt.Sprintf(``, alt, src) |
| 287 | selection.BeforeHtml(md) |
| 288 | selection.Remove() |
| 289 | } |
| 290 | }) |
| 291 | return doc |
| 292 | } |
| 293 | |
| 294 | //[ok]handle tag h1~h6 |
| 295 | func handleHead(doc *goquery.Document) *goquery.Document { |