In a comment, Steve asks how I format code in my blog. Here’s the answer:
- Write the code in Visual Studio. Include correct references, ‘using’ directives, helper classes, fields, etc. Make sure the code builds. (I really should use NUnit to make sure it works.) It’s amazing how much sample code out there is plain broken. Not just in blogs, but even in expensive books.
- Because I’m using Whidbey, I get nice colorization of types. (You see them showing in Bold Navy.) I love this feature.
- Even though the blogging site I’m using lets me write in a WYSIWIG editor on a web page, I usually write the blog in Word. For some reason, it’s really a pain to get good formatting in an HTML WYSIWIG editor. It inserts blank space where I don’t want it, forgets my font settings, etc. When I paste in code, it loses indenting & font settings.
- I copy code from VS & paste it in Word. VS fills the clipboard with (at least) two formats: text and RTF. Word prefers the RTF, so its gets my formatting. I think that RTF pasting into the HTML editor is extra-broken.
- I select the pasted code & click the toolbar button to draw a nice box around the code.
I also have a predefined style called “code” that I use when there’s a bit of code in the middle of a sentence. There’s a typesetting style where langue étrangère should be italicized. I’m doing the same thing by putting keywords & indentifiers in fixed width, I guess.