« Riding the Bus | Main | Get Environment Variables from a .CMD script »

October 20, 2005

Prettifying Monad Code Listings

This is cool. Wes Haggard started using Monad a couple of weeks ago and he already has added Monad support to CodeHTMLer. When I show code I replace spaces with &nbsp;, change < to &lt;, etc. by hand. But this thing does the needed encoding (well OK it just slaps <pre> around the whole thing) and adds colors also.

Here's a comparison. Old way:

[int]$n = $args[0]
for ($i = 2; $i -le $n; $i++) {
    while (([int]($n / $i) * $i) -eq $n) {
        $i
        $n /= $i
    }
}

With CodeHTMLer:

[int]$n = $args[0]
for ($i = 2; $i -le $n; $i++) {
    while (([int]($n / $i) * $i) -eq $n) {
        $i
        $n /= $i
    }
}

As my son would say, Nice! I'm continually impressed by what the Monad community is doing.

Posted by AdamBa at October 20, 2005 10:21 PM

Trackback Pings

TrackBack URL for this entry:
http://proudlyserving.com/cgi-bin/mt-tb.cgi/347

Comments

Glad you like it. If you don't like the pre you can also use the 'convert whitespaces' option instead. Let me know if there is anything else you think should be highlighted. I thought about highlighting the operators (-eq,-lt,etc) as well but decided not to.

Posted by: Wes at October 21, 2005 07:40 AM