Posting source code on WordPress.com with Windows Live Writer

The first time I tried to post some code to WordPress.com it took about an hour longer than I thought it would. The first step was learning of the existence of the WordPress sourcecode tag. It took some googling to find this support article on Posting Source Code. It can do different sorts of syntax highlighting based on the language attribute which is pretty nice (although I would prefer Github gists but it’s not an option right now). I was writing a blog post about Ruby and so could use the sourcecode tag to get Ruby syntax highlighting. Unfortunately, I only discovered this after writing my post in Live Writer and trying to publish it. I had used the pre and code html tags and on publishing all code formatting was promptly stripped away.

Another problem that I had was that WordPress and Live Writer interpreted the Ruby symbol, :Debug, as Open-mouthed smileebug. The solution is to turn off the automatic resolution of text emoticons to graphical emoticons (hat-tip to Daniel Persson for that one). In Live Writer this option can be found under Options->Editing->Replace text emoticons with emoticon graphics. And for WordPress.com, Settings->Writing->Formatting->Convert emoticons like :-) and :-P to graphics on display.

And the last step to easily be able to paste in source code into Live Writer, is to use a code formatting plugin. I am trying out the WLW Source Code Highlighter Plugin and it is much easier than switching to the HTML view in WordPress and manually writing out the sourcecode tag and attributes. Recommended if you’re using Windows Live Writer and posting to WordPress.com.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s