mirror of https://github.com/muesli/mastotool
Make cleanupContent a separate function
This commit is contained in:
parent
d50115e2e7
commit
388aa2c5ec
18
stats.go
18
stats.go
|
@ -42,6 +42,17 @@ type stats struct {
|
||||||
Responses map[string]int64
|
Responses map[string]int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanupContent(content string) string {
|
||||||
|
// clean up toot for terminal output
|
||||||
|
content = strings.Replace(content, "<br>", "\n", -1)
|
||||||
|
content = strings.Replace(content, "<p>", "\n", -1)
|
||||||
|
content = strings.Replace(content, "</p>", "", -1)
|
||||||
|
content = html.UnescapeString(stripper.Sanitize(content))
|
||||||
|
content = strings.TrimSpace(strings.Replace(content, "\n", " ", -1))
|
||||||
|
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
func parseToot(status *mastodon.Status, stats *stats) error {
|
func parseToot(status *mastodon.Status, stats *stats) error {
|
||||||
// handle mentions
|
// handle mentions
|
||||||
for _, m := range status.Mentions {
|
for _, m := range status.Mentions {
|
||||||
|
@ -92,12 +103,7 @@ func parseToot(status *mastodon.Status, stats *stats) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up toot for terminal output
|
content := cleanupContent(status.Content)
|
||||||
content := strings.Replace(status.Content, "<br>", "\n", -1)
|
|
||||||
content = strings.Replace(content, "<p>", "\n", -1)
|
|
||||||
content = strings.Replace(content, "</p>", "", -1)
|
|
||||||
content = html.UnescapeString(stripper.Sanitize(content))
|
|
||||||
content = strings.TrimSpace(strings.Replace(content, "\n", " ", -1))
|
|
||||||
|
|
||||||
// handle replies
|
// handle replies
|
||||||
if status.InReplyToID != nil {
|
if status.InReplyToID != nil {
|
||||||
|
|
Loading…
Reference in New Issue