Rework fixers to decide what to use and move dehtmlify process in them.

Added githubv fixer.
This commit is contained in:
2026-08-09 07:27:19 +05:00
parent f37a1422e2
commit 7b13dce342
4 changed files with 48 additions and 17 deletions
+19 -4
View File
@@ -1,11 +1,26 @@
package fixers
import "strings"
import (
"log/slog"
"strings"
"github.com/mmcdole/gofeed"
"github.com/prodigeris/html2text"
)
func opennetFixer(item *gofeed.Item) (string, string) {
oldBody, err := html2text.FromString(item.Description, html2text.Options{
PrettyTables: true,
})
if err != nil {
slog.Error("Failed to de-HTMLify opennet body!", "error", err.Error())
return item.Title, item.Description
}
func opennetFixer(title, body string) (string, string) {
newBody := &strings.Builder{}
for line := range strings.Lines(body) {
for line := range strings.Lines(oldBody) {
if strings.HasPrefix(line, "Источник") {
continue
}
@@ -13,5 +28,5 @@ func opennetFixer(title, body string) (string, string) {
_, _ = newBody.WriteString(line)
}
return title, newBody.String()
return item.Title, newBody.String()
}