Markdown in your EmailThu 09 August 2012 by Lars Kellogg-Stedman
I really like Markdown, a minimal markup language designed to be readable as plain text that can be rendered into structurally valid HTML. Markdown is already used on sites such as GitHub and all the StackExchange sites.
I use Markdown often enough that it's become ingrained in my fingers, to the point that I've started unconsciously using Markdown syntax in my email. This isn't particularly useful by itself, although it means that I can take a message and render it to something pretty if I decide it needs to go somewhere other than my sent mail folder.
I thought it would be fun to implement something that would actually render Markdown syntax in my outbound email and render it into an HTML attachment. I spent a little time last night putting together a small Python script that does exactly that:
- It looks for a leading
<!-- markdown -->in a message body.
- It renders the markdown to HTML.
- It transforms the message into a
- It attaches the rendered content as
- It attaches the original message as
- It attaches any signature that was found in the original message as
I have Mutt configured to pass outbound email through this filter by setting the
...to point to a small shell script that passes everything off to procmail:
#!/bin/sh exec procmail -m msmtp_args="$*" $HOME/.procmail/rc.sent
procmail filters outbound messages before sending them via
# Render markdown email to HTML :0f | $HOME/.mutt/bin/markdownmail # Send via msmtp :0w | msmtp $msmtp_args
It's not especially robust but it seems to work so far.