aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--internal/feed/mail.go15
2 files changed, 13 insertions, 4 deletions
diff --git a/go.mod b/go.mod
index 0ff1224..1d1041d 100644
--- a/go.mod
+++ b/go.mod
@@ -11,6 +11,6 @@ require (
github.com/google/go-cmp v0.4.0
github.com/google/uuid v1.1.1
github.com/mmcdole/gofeed v1.0.0-beta2.0.20200331235650-4298e4366be3
- golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect
+ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
)
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index 0a8bd10..f77987e 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -16,6 +16,7 @@ import (
"github.com/emersion/go-message"
"github.com/emersion/go-message/mail"
"github.com/gabriel-vasile/mimetype"
+ "golang.org/x/net/html"
"github.com/Necoro/feed2imap-go/internal/feed/template"
"github.com/Necoro/feed2imap-go/internal/http"
@@ -240,6 +241,13 @@ func getBody(content, description string, bodyCfg config.Body) string {
}
}
+func startsWithText(str string) bool {
+ reader := strings.NewReader(str)
+ tokenizer := html.NewTokenizerFragment(reader, "")
+
+ return tokenizer.Next() == html.TextToken
+}
+
func (item *item) buildBody() {
feed := item.feed
feedUrl, err := url.Parse(feed.Url)
@@ -248,6 +256,9 @@ func (item *item) buildBody() {
}
body := getBody(item.Content, item.Description, feed.Body)
+ if body != "" && startsWithText(body) {
+ body = "<br />" + body
+ }
if !feed.InclImages {
item.Body = body
@@ -257,9 +268,7 @@ func (item *item) buildBody() {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
if err != nil {
log.Errorf("Feed %s: Item %s: Error while parsing html content: %s", feed.Name, item.Link, err)
- if body != "" {
- item.Body = "<br />" + body
- }
+ item.Body = body
return
}
rtato/gui/windows/update.py?id=5ae4fda6f6fdcc8a21253dd6dc9d6051c99af34f&follow=1'>First quick hack to have a world listRené 'Necoro' Neumann3-2/+24 2009-09-06Re-formulate the debug message if a menu file has been found.René 'Necoro' Neumann1-1/+1 2009-09-06Update ui files with gladeRené 'Necoro' Neumann8-72/+167 2009-09-06Install .menuRené 'Necoro' Neumann1-1/+1 2009-09-06Automatic loading of the external menuRené 'Necoro' Neumann2-3/+25 2009-09-06Make glade update the MainWindow.ui fileRené 'Necoro' Neumann1-85/+134 2009-09-06Moved the menu to an extra fileRené 'Necoro' Neumann2-210/+207 2009-09-05One database instance is enough :)René 'Necoro' Neumann1-7/+18 2009-09-05Print database type at the bottom of exceptions. NOTE: This does not handle m...René 'Necoro' Neumann2-1/+6 2009-09-05Fix an error, where a category vanishes after refreshing, using the EixSQLDat...René 'Necoro' Neumann2-1/+19 2009-09-03And here is the debugging again :) ... using ctypesRené 'Necoro' Neumann1-1/+8 2009-09-03Screw debugging ... prefer the ctypes approach to get rid of yet another c-mo...René 'Necoro' Neumann3-27/+11 2009-09-03Use this wrapper instead of ctypes to set the textdomain and stuff for the gt...René 'Necoro' Neumann1-9/+5 2009-09-03Add small wrapper to C-gettextRené 'Necoro' Neumann2-1/+22 2009-08-31Update messages.potRené 'Necoro' Neumann1-42/+94 2009-08-31Removed the gtk- strings from translationsRené 'Necoro' Neumann7-3639/+3479 2009-08-31Removed the 'translatable' attribute from 'gtk-*' stringsRené 'Necoro' Neumann5-11/+11 2009-08-31Removed TODO. Renamed ChangeLog to TODORené 'Necoro' Neumann2-40/+0 2009-08-27Only import stuff if necessaryRené 'Necoro' Neumann1-8/+8 2009-08-25Release the threadQueue-Lock in syncv0.13René 'Necoro' Neumann1-0/+1 2009-08-25Updated portugese translationAlberto Federman Neto1-650/+687 2009-08-15Update spanish translationDaniel Halens1-245/+258 2009-08-15Use boolean flags instead of obscure C flags for ipc.MessageQueueRené 'Necoro' Neumann3-13/+15 2009-08-15TypoRené 'Necoro' Neumann1-1/+1 2009-08-15Enhanced the extensions.shRené 'Necoro' Neumann1-3/+8 2009-08-15Move eix-format to correct locationRené 'Necoro' Neumann1-0/+0