Browse Source

support \b in text tempaltes

Umputun 5 years ago
parent
commit
2e2c0f3eb3
2 changed files with 3 additions and 2 deletions
  1. 2 1
      app/main.go
  2. 1 1
      app/rss/notify.go

+ 2 - 1
app/main.go

@@ -8,6 +8,7 @@ import (
 	"os"
 	"os/signal"
 	"runtime"
+	"strings"
 	"syscall"
 	"text/template"
 	"time"
@@ -101,7 +102,7 @@ func do(ctx context.Context, notif notifier, pub publisher.Interface, tmpl strin
 				// template failed to parse record, backup predefined format
 				return fmt.Sprintf("%s - %s", r.Title, r.Link)
 			}
-			return format(b1.String(), 275)
+			return strings.Replace(format(b1.String(), 275), `\n`, "\n", -1) // \n in template
 		})
 		if err != nil {
 			log.Printf("[WARN] failed to publish, %s", err)

+ 1 - 1
app/rss/notify.go

@@ -107,7 +107,7 @@ func (n *Notify) feedEvent(feed *gofeed.Feed) (e Event, err error) {
 	e.ChanTitle = feed.Title
 	e.Title = feed.Items[0].Title
 	e.Link = feed.Items[0].Link
-	e.Text = "\n" + feed.Items[0].Description
+	e.Text = feed.Items[0].Description
 	e.GUID = feed.Items[0].GUID
 
 	return e, nil