Converting Markup to e-mails
From rubygems.org
gem install markup-email --no-ri --no-rdoc
# Then use the executables
markup-email [file] [options]
From source (without gems)
git clone https://github.com/Demonstrandum/MarkupEmail.git && cd MarkupEmail
cat *.gemspec # Read through and download all runtime dependencies
ruby -Ilib bin/markup-email [file] [options] # Then you can use the program
Basic usage:
markup-email [markup file] [options]
e.g. markup-email -s email.md -t 'Special E-mail'
Options:
Option | Description |
---|---|
-s , --sanitize |
Sanitizes all html/markdown by removing potentially harmful tags or their attributes |
-t , --title |
The subsequent word/argument will be set as the title |
-h , --help, help |
Brings up the help menu (similar as this) |
Your chosen markdown requires these packages accordingly:
- .markdown, .mdown, .mkdn, .md --
gem install commonmarker
- .textile --
gem install RedCloth
- .rdoc --
gem install rdoc -v 3.6.1
- .org --
gem install org-ruby
- .creole --
gem install creole
- .mediawiki, .wiki --
gem install wikicloth
- .rst --
python3 -m pip install sphinx
- .asciidoc, .adoc, .asc --
gem install asciidoctor
- .pod -- Pod::Simple::XHTML comes with Perl >= 5.10.
Delete the example .html
in this repo's examples
folder and generate it yourself
$ markup-email -s -t veryExampleWow examples/example.md
Title is : veryExampleWow
Filename is : veryExampleWow.html
Markup/HTML will be sanitized,
(`class=...` attributes and <script> tags will be disalowed).
Then open examples/veryExampleWow.html
in your browser and see for yourself, then you can open it in a text-editor, view the source and copy it in to your e-mail editor as HTML
source.
Create a file named either: .markup-email.css
, .email.css
, .markup.css
or .markdown.css
in your home directory (~
) edit it with an editor, e.g. vim: vim ~/.email.css
Add your custom css for your email in either one of these files.
e.g.
body { width: 600px; } /* As opposed to 980px */
article, .markdown-body {
border-radius: 0; /* 5px */
padding: 20px; /* 45px */
}
.markdown-body:first-child {
box-shadow: none; /* 0 10px 50px rgba(0, 0, 0, 0.2) */
}
Inspect the email/site in the browser to prototype and learn about how to style it.
Can also be used in Ruby
require 'markup_email'
file = '~/emails/hello.md' # Markup file path
title = 'Hello, World' # Title of the email
markup = MarkupEmail::Convert.new(file, title, sanitize)
puts markup.content # Will print the pure HTML
markup.write "#{File.dirname file}/#{File.basename(file).split('.')[0..-2].join('.')}-converted.html" # Makes a new file
# If `file` was equal to "hello.there.md"
# then the new file from `markup.write()` would be called
# "hello.there-converted.html"
If this is not sufficient, perhaps see the rubydoc.info for autogenerated documentation.