Markdown
John Gruber has released Markdown, a plain text to (X)HTML language and tool. It is similar in function to Textile, which I’ve been using since I started this blog. Markdown’s formatting is inspired by plaintext e-mail formatting, and has the added advantage that Markdown-encoded text is, basically, legible; even more so than Textile-encoded text. To really see this in action, look at the Markup-encoded version of the Markup home page. This really sold me on the idea of using Markup here on the blog. At some point I intend to do a rigorous, feature-by-feature comparison of the two at some point; for now I just want to play with Markdown.
Markdown (the tool) is implemented in Perl, and is both a command-line tool and a Movable Type plugin in a single file. I had intended to write a Blosxom plugin for Markdown, however, Markdown.pl is also a Blosxom plugin! Very nice. One caveat - You must rename the file to Markdown in order for Blosxom to recognize it as a plugin.
As written, Markdown-as-Blosxom-plugin processes every entry as Markdown-encoded text. This would require me to convert all of my existing entries, which I’m not looking to do. Instead, I modified Markdown.pl slightly to work like the Blosxom Textile plugin- if the Blosxom story header includes meta-markup: markdown, then Markdown is invoked to process the story text (requires the meta plugin). The modified story() looks like this:
sub story {
my($pkg, $path, $filename, $storyref, $titleref, $bodyref) = @;
if ($meta::markup eq 'markdown') {
$$title_ref = Markdown($$title_ref);
$$body_ref = Markdown($$body_ref);
}
1;
}
So how does it work? You’re soaking in it. This entry is written Markdown. So far, so good. I’ll post again later on my Markdown-vs-Textile impressions.
Update: The code above is obsolete. A much more robust version is here.
You can leave a response, or trackback from your own site.
Looks nice
It seems to combine all my favorite things from Restructured Text and Textile. I’ll have to figure out the licensing issues and possibly do a python port of it. I can see this as a very good method of long-term document storage.
(defined $meta::markup) ?
I find that if the story header doesn’t include $meta::markup, I get an uninitialized value error in my logs… Would it be appropriate to use the following instead? (hope this is readable without being able to format it.)
defined indeed
Good Catch, ArC. Thanks. Incidentally, this isn’t the latest version of the code. I’ve added an update to this article pointing to a newer post containing a more robust version of the code. I’ve also updated that article with your fix.