Skip to content

Commit

Permalink
added godown html2markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Seeger committed Feb 17, 2020
1 parent 6901206 commit 39388dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/Flaque/filet v0.0.0-20190209224823-fc4d33cfcf93
github.com/PuerkitoBio/goquery v1.5.0
github.com/Skarlso/html-to-markdown v0.0.0-20191210071215-2cf06e949e49
github.com/cseeger-epages/godown v0.0.0-20180312012330-2e9e17e0ea51
github.com/dsnet/compress v0.0.1 // indirect
github.com/emersion/go-imap v1.0.0-rc.2
github.com/emersion/go-message v0.11.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/corpix/uarand v0.0.0/go.mod h1:JSm890tOkDN+M1jqN8pUGDKnzJrsVbJwSMHBY4zwz7M=
github.com/cseeger-epages/godown v0.0.0-20180312012330-2e9e17e0ea51 h1:wRkDqYlQratKLUdtdpAeyeRolvJ5y/L/7zeQ3Be8vOw=
github.com/cseeger-epages/godown v0.0.0-20180312012330-2e9e17e0ea51/go.mod h1:YH5dvqBkWk+/05C+IsYsAIsQVkiSRqzgaYp2aogXjIc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
9 changes: 8 additions & 1 deletion lib/mattermost.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package mail2most

import (
"bytes"
"encoding/base64"
"fmt"
"strings"

"github.com/cseeger-epages/godown"
"github.com/k3a/html2text"
"github.com/mattermost/mattermost-server/model"
)
Expand Down Expand Up @@ -51,7 +53,12 @@ func (m Mail2Most) PostMattermost(profile int, mail Mail) error {
}

if m.Config.Profiles[profile].Mattermost.ConvertToMarkdown {
// tbd convert body to markdown
var b bytes.Buffer
err := godown.Convert(&b, strings.NewReader(body), nil)
if err != nil {
return err
}
body = b.String()
} else if m.Config.Profiles[profile].Mattermost.StripHTML {
body = html2text.HTML2Text(body)
mail.Subject = html2text.HTML2Text(mail.Subject)
Expand Down

0 comments on commit 39388dc

Please sign in to comment.