https://github.com/demonstrandum/markupemail
Converting Markup to E-mails
https://github.com/demonstrandum/markupemail
email html markdown markup markup-converter rst ruby
Last synced: 2 months ago
JSON representation
Converting Markup to E-mails
- Host: GitHub
- URL: https://github.com/demonstrandum/markupemail
- Owner: Demonstrandum
- License: gpl-3.0
- Created: 2017-07-15T10:34:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-24T12:28:01.000Z (almost 9 years ago)
- Last Synced: 2025-04-14T15:18:12.569Z (about 1 year ago)
- Topics: email, html, markdown, markup, markup-converter, rst, ruby
- Language: Ruby
- Homepage:
- Size: 64.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MarkupEmail
> Converting Markup to e-mails
## Installation
From [rubygems.org](https://rubygems.org/gems/markup-email)
```shell
gem install markup-email --no-ri --no-rdoc
# Then use the executables
markup-email [file] [options]
```
From source (without gems)
```shell
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
```
## Usage
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
```shell
$ markup-email -s -t veryExampleWow examples/example.md
Title is : veryExampleWow
Filename is : veryExampleWow.html
Markup/HTML will be sanitized,
(`class=...` attributes and tags will be disalowed).
```
### E-mail it
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.
## Add custom styling
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.
```css
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.
## In Ruby
*Can* also be used in Ruby
```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](http://www.rubydoc.info/gems/markup-email/1.2.4/) for autogenerated documentation.