feat/unsafe html (#11)

* add unsafe html render and plugins

* small env fix

* update UNSAFE_HTML env

Co-authored-by: Maas Lalani <maas@lalani.dev>

---------

Co-authored-by: Maas Lalani <maas@lalani.dev>
This commit is contained in:
egor
2023-07-20 23:42:37 +03:00
committed by GitHub
parent 85b1f54563
commit f8dfdafcd2
2 changed files with 21 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/resendlabs/resend-go"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
renderer "github.com/yuin/goldmark/renderer/html"
)
const TO_SEPARATOR = ","
@@ -41,7 +43,21 @@ func sendEmail(to []string, from, subject, body string, paths []string) error {
html := bytes.NewBufferString("")
// If the conversion fails, we'll simply send the plain-text body.
_ = goldmark.Convert([]byte(body), html)
if unsafe {
markdown := goldmark.New(
goldmark.WithRendererOptions(
renderer.WithUnsafe(),
),
goldmark.WithExtensions(
extension.Strikethrough,
extension.Table,
extension.Linkify,
),
)
_ = markdown.Convert([]byte(body), html)
} else {
_ = goldmark.Convert([]byte(body), html)
}
request := &resend.SendEmailRequest{
From: from,