Published on

18 Feb 2008

Last updated

14 May 2010

Markdown extensions

John Grubers’s Markdown is a specification and a program for turning plain text into HTML. This is already very convenient, but sometimes you would like to automate a little more.

This site is written in Python, so it makes sense to use the Python port of John Gruber’s original implementation. In addition to integrating better with a Python-based site, it is comparatively easy to extend this particular implementation. Quite a few extensions are available – and it’s easy to write additional extensions.

I have written an extension that adds several typographic niceties – “smart” quotes, en– and em—dashes, and ellipses… This is mostly automated (en- and em-dashes must be manually specified by -- or ---). The specific rules used can be configured (although that interface is not particularly user-friendly), and backslash-escaped characters will not be considered (-- becomes –, but \-\- becomes --). Most concepts were stolen from SmartyPants or Typogrify, but the implementation is my own.

I also have a rather trivial extension that turns headers into <img> tags. Note that it does not generate the required images – PIL or another imaging library may be helpful.