Posting with Code

As a general rule, I write these posts in HTML, because I'm a control freak. I kind of have a problem with relinquishing control, at least when it comes to things on a computer. Until relatively recently, I ran Slackware for my Linux box. At work, I write lots of scripts to do things I want. I write far more scripts than I reuse ones that someone else wrote.

I want to be able to post code here, and I want to be able to mark it up a little. For example, I like putting things in bold to point them out. To do this, I use <pre> tags and <code> tags together. Sometimes I want to show snippets of, say, XML. In that case, I need to escape all of the left angle brackets to prevent them from being interpreted.

The solution, of course, is to write a script. I wrote a little something in Ruby that formats the code blocks as it generates the output file. I can probably throw in whatever else I need into the script, too. I'm putting a Makefile in my local directory, so I can easily generate the formatted versions of posts I write in easy-to-read HTML.

To test it out a bit, here's the relevant part of the Makefile. I learned how to define an inference rule.

formatted = \
    20090514-1_posting-code.form  \

	ruby $(FORMATTER) $< $@

$(formatted) :

It only seems proper at this point to mention the post that helped me decide which blogging service to choose. The main part in bold in the middle is what did it: WordPress charges you to edit your CSS; Blogger does not. What else is there, when you plan to write your posts in GVIM offline?


Post a Comment