fix: display images in epub

This commit is contained in:
lapwat
2021-12-09 23:40:55 +01:00
parent d5971a2819
commit d593a74e6e
5 changed files with 150 additions and 99 deletions

View File

@@ -41,15 +41,17 @@ func NewChapterFromURL(url string, images bool) chapter {
content := strings.ReplaceAll(article.Content, "\n", "")
if images {
// Load the HTML document
// parse html content
doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
if err != nil {
log.Fatal(err)
}
// Find the review items
// extract images only
content = ""
doc.Find("img").Each(func(i int, s *goquery.Selection) {
content, _ = goquery.OuterHtml(s)
newContent, _ := goquery.OuterHtml(s)
content += newContent
})
}