fabric/converter/html_readability.go

26 lines
534 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package converter
import (
"bytes"
"github.com/go-shiori/go-readability"
)
// HtmlReadability Convert HTML input into a clean, readable view
// args
//
// html (string): full data of web page
//
// return
//
// viewContent (string): html main content
// err (error): parser error
func HtmlReadability(html string) (ret string, err error) {
buf := bytes.NewBufferString(html)
var article readability.Article
if article, err = readability.FromReader(buf, nil); err != nil {
return
}
ret = article.TextContent
return
}