Better lynx args
Anirudh Oppiliappan x@icyphox.sh
Sun, 26 Sep 2021 10:22:32 +0530
3 files changed,
13 insertions(+),
2 deletions(-)
M
go.mod
→
go.mod
@@ -10,6 +10,6 @@ github.com/joegrasse/mail v1.0.0
github.com/joegrasse/mime v0.0.0-20151001172835-f543c4783e35 // indirect github.com/joho/godotenv v1.3.0 github.com/microcosm-cc/bluemonday v1.0.15 - golang.org/x/net v0.0.0-20210908191846-a5e095526f91 // indirect + golang.org/x/net v0.0.0-20210908191846-a5e095526f91 mvdan.cc/xurls/v2 v2.3.0 )
M
mail/send.go
→
mail/send.go
@@ -32,6 +32,9 @@ return err
} plainContent, err := reader.MakePlaintext(htmlContent) + if err != nil { + return fmt.Errorf("making plaintext: %w\n", err) + } email := mail.New() email.Encryption = mail.EncryptionTLS
M
reader/plain.go
→
reader/plain.go
@@ -1,12 +1,20 @@
package reader import ( + "fmt" "os/exec" "strings" ) func MakePlaintext(html []byte) ([]byte, error) { - args := []string{"-image_links", "-dump", "-stdin"} + fmt.Println(string(html)) + args := []string{ + "-dont_wrap_pre", + "-display_charset=UTF-8", + "-image_links", + "-dump", + "-stdin", + } cmd := exec.Command("lynx", args...) cmd.Stdin = strings.NewReader(string(html)) out, err := cmd.Output()