1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Add a rewrite rule to remove clickbait titles

This commit is contained in:
Romain de Laage 2023-04-08 11:02:36 +02:00 committed by Frédéric Guillot
parent 8161085714
commit 33c4b5188c
4 changed files with 379 additions and 170 deletions

View file

@ -367,3 +367,17 @@ func removeTables(entryContent string) string {
output, _ := doc.Find("body").First().Html()
return output
}
func removeClickbait(entryTitle string) string {
titleWords := []string{}
for _, word := range strings.Fields(entryTitle) {
runes := []rune(word)
if len(runes) > 1 {
// keep first rune as is to keep the first capital letter
titleWords = append(titleWords, string([]rune{runes[0]})+strings.ToLower(string(runes[1:])))
} else {
titleWords = append(titleWords, word)
}
}
return strings.Join(titleWords, " ")
}