February 5, 2004 · Dan Cederholm

SimpleCode

If you're like me, than you're starting to get tired of turning XHTML into entity-encoded markup, suitable for <code> examples. Today I thought I'd whip up a quick Perl script that will take ordinary markup, process it and do all of the turning of < to &lt; and > to &gt; -- for you.

It will also recognize double spaces (to nicely format nesting) and turn those into "&#160;&#160;" (it will do the same for four spaces and six spaces as well).

screenshot

SimpleCode intends to make my life easier. It's essentially in beta and took only an hour to put together -- in fact I'll bet there's something out there that already exists and I just didn't think to look earlier. I'm sure it's missing some features, and that's where you come in. It'll come in handy for the SimpleQuiz examples -- and I'd venture to say it would help for those commenting as well.

Feel free to use it -- and grab the source code to put on your own server. It's a single, self-contained file that just needs to be dropped in your cgi-bin. Set permissions to 755 and you're good to go.

Update: Jesper has created a neat and tidy JavaScript version, and also helped me simplify a bit of the Perl source as well. v02 (and v03) already!