Bloggers often find that while writing posts and articles, adding simple markup to the text is very useful. Things like bold, italic or fixed font text, lists, headers, paragpahps, quotes, links and so on. HTML is the ultimate markup language of the web, but it is quite heavy-weight and very tiresome to type, especially for things like lists.

Enter lightweight markup languages – simple syntax designed to be easy for a human to enter, and easy to read in its raw form. There are quite a lot of such languages out there, and the one I’m using is Textile. Textile supports all the features I listed above and much more. Compare:

*bold text*


<strong>bold text</strong>


* A first item
* A second item
* A third item


<li>A first item</li>
<li>A second item</li>
<li>A third item</li>

The best Textile reference I know of was written by the Ruby hacker named Why. Here is his quick reference and full reference for Textile. Why is also the author of the Ruby library RedCloth – a converter from Textile to HTML. Another very useful resource for Textile is Textism – an online Textile to HTML converter which you can use to try Textile out.

So how am I using Textile ? I write my posts in simple text files on my computer using Scite. To convert the file to HTML, I’ve hooked up a keystroke (Ctrl+9) that calls a script. Now, since I’m much more comfortable with Perl than with Ruby for scripting, all the scripts I run from inside Scite are in Perl. All the script does is invoke the redcloth Ruby program that gets installed when you install the RedCloth gem:

use strict;
use warnings;
use File::Basename;

my $filename = $ARGV[0];
my ($filename_only, $dirname, $ext) = fileparse($filename, qr/\.[^.]*/);
my $out_filename = $dirname . $filename_only . ".html";

# Gotta love running a Ruby program from inside Perl ;-)
system("redcloth \"$filename\" > \"$out_filename\"");

print "Created $out_filename\n";

I then take the generated HTML and paste it into my blog posts. I tried other ways, but they have all failed. Using the Wordpress Textile plugin didn’t work because it clashed with the other processors I use in Wordpress (like the one to translate special characters in code blocks, for instance). I also tried employing a Perl module for the Textile translation, but it doesn’t fully comply to the Textile reference, and RedCloth is much better.

All in all, using Textile makes me more productive. Instead of breaking my teeth on HTML tags, I can write in a simple and intuitive markup that is almost like normal text, and convert it to valid HTML automatically.