Custom function html2text.
parent
0eb73d75a8
commit
df43f758e9
15
feed.go
15
feed.go
|
@ -7,7 +7,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
strip "github.com/grokify/html-strip-tags-go"
|
"regexp"
|
||||||
|
|
||||||
"github.com/mmcdole/gofeed"
|
"github.com/mmcdole/gofeed"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,8 +51,8 @@ func forwardLastFeed(url string) {
|
||||||
|
|
||||||
if time.Since(postAge) < Zint {
|
if time.Since(postAge) < Zint {
|
||||||
|
|
||||||
TheTitle := fmt.Sprintf("[News from %s ]", strip.StripTags(feed.Title))
|
TheTitle := fmt.Sprintf("[News from %s ]", html2text(feed.Title))
|
||||||
TheBody := fmt.Sprintf("%s\n\n %s\n\n %s\n\n%s\n ", strip.StripTags(b.Author.Name), strip.StripTags(b.Title), strip.StripTags(b.Description), b.Link)
|
TheBody := fmt.Sprintf("%s\n\n %s\n\n %s\n\n%s\n ", html2text(b.Author.Name), html2text(b.Title), html2text(b.Description), b.Link)
|
||||||
|
|
||||||
postOnMastodon(TheBody, TheTitle)
|
postOnMastodon(TheBody, TheTitle)
|
||||||
log.Println("New content from: ", feed.Title, b.Title, feed.Description)
|
log.Println("New content from: ", feed.Title, b.Title, feed.Description)
|
||||||
|
@ -108,3 +109,11 @@ func fileByLines(filename string) (blurls []string) {
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func html2text(html string) string {
|
||||||
|
|
||||||
|
re := regexp.MustCompile(`<[^>]*>`)
|
||||||
|
|
||||||
|
return re.ReplaceAllString(html, "")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue