On blogging tools

One of the obstacles to frequent posting (at least mine) is that the types of posts I typically make include code.  Code that I would like to be formatted nicely.  Unfortunately, this previously meant hand-crafting HTML to make it all look nice.  In some cases, I could write up scripts in Visual Studio and paste them into an editor which would (mostly) preserve the formatting, but having to write batch files in VS seems hugely overkill.  Anyway, since that was such a pain, I didn't post often.

Enter Windows Live Writer.  Everyone else is blogging about it, so hey, why shouldn't I?  Out of the box, it's very, very nice (and free, to boot!).  It's a truly WYSIWYG editor (not the typical WYSI-more or less-WYG-with a few little problems here and there) and that handles all of my typical blogging needs.  Except the whole code formatting thing.  Aha, you say, how does that help? 

Easy. 

WLW supports plugins, and they're (evidently) easy to develop.  Even though it's still in beta, there are dozens of plugins already.  A few of those plugins enable code formatting.  I've chosen to use Steve Dunn's cleverly named Code Formatter Plugin, which uses Actipro's CodeHighlighter web control.  Most of the code highlighters out there only seem to support the Visual Studio types of code (your C, your VB.Net, etc.).  Try to get scripts highlighted and forget about it.  This one does, though, and even though it's not quite the same style of highlighting I'm used to, it's way better than nothing.

Take the scriptlet I wrote in this post.  Hand-styling that was a huge pain, and all I really did was keep the indenting and ensure it was all in a fixed-width font.  But all that indenting added up to a lot of  's and it was easy to lose track of how many I'd already done.

With this plugin to WLW, though, it's a matter of clicking "Insert Formatted Code" or "Insert Clipboard as Code" and you get this instead:

 

 1 for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (
2     for /f "delims=:. tokens=1-4" %%m in ("%TIME%") do (
3         set FILENAME=basename-%%c-%%b-%%a-%%m%%n%%o%%p
4     )
5 )

Line numbers and everything.  In the future, I'll skip the line numbers for bits of script I intend for people to copy and paste, but to illustrate points, I'll include them.

Ok, enough rah-rah from me.  I have scripts to write.

(But seriously. If you blog, this is an awesome tool.)