1
0
mirror of https://github.com/vanng822/go-premailer.git synced 2025-02-06 02:15:13 +00:00
Nguyen Van Nhu 5cd3ea43d3
All checks were successful
Go / build (push) Successful in 47s
Merge pull request #36 from vanng822/dependabot/go_modules/golang.org/x/net-0.34.0
Bump golang.org/x/net from 0.33.0 to 0.34.0
2025-01-31 19:58:38 +01:00
2024-05-07 09:01:11 +02:00
2015-05-05 09:26:30 +02:00
2015-02-22 11:58:22 +01:00
2019-05-04 08:36:38 +02:00
2024-05-01 18:04:57 +02:00

go-premailer

Inline styling for HTML mail in golang

Document

GoDoc Go Report Card

install

go get github.com/vanng822/go-premailer/premailer

Example

import (
	"fmt"
	"github.com/vanng822/go-premailer/premailer"
	"log"
)

func main() {
	prem, err := premailer.NewPremailerFromFile(inputFile, premailer.NewOptions())
	if err != nil {
		log.Fatal(err)
	}
	
	html, err := prem.Transform()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(html)
}

Input

<html>
<head>
<title>Title</title>
<style type="text/css">
	h1 { width: 300px; color:red; }
	strong { text-decoration:none; }
</style>
</head>
<body>
	<h1>Hi!</h1>
	<p><strong>Yes!</strong></p>
</body>
</html>

Output

<html>
<head>
<title>Title</title>
</head>
<body>
	<h1 style="color:red;width:300px" width="300">Hi!</h1>
	<p><strong style="text-decoration:none">Yes!</strong></p>
</body>
</html>

Commandline

> go run main.go -i your_email.html
> go run main.go -i your_mail.html -o process_mail.html
Description
Inline styling for html mail in golang
Readme MIT 214 KiB
Languages
Go 96.9%
HTML 2.3%
Makefile 0.8%