.Net, Windows Live Writer, WPF

Windows Live Writer Plugin for WordPress.com [sourcecode] Highlighter

Recently been wanting to blog more and more about code and give my posts some more punch by providing some code samples. The one thing that I always notice about other blog posts were the nice little syntax highlight boxes for code. You know the one that has the line numbers and allows you to copy to the clipboard or print.

So I set out to get my hands on a syntax highlight plugin that I could use and found a lot of them out there are really neat and well put together. One of the really important things for me was to also find a plugin for Windows Live Writer (which is simply one of the best tools). So long story short, I found my plugin’s and was ready to go.

One small problem, I am blogging on WordPress.com.

So that means, no pluggin directory, no JavaScript files, nothing. I did some reading on the WordPress.com website and found out that they do have and support a syntax highlighter for code. Wow… this was great. Now the only thing left was to find a plugin for Windows Live Writer that would work with this type of syntax highlighter.

If you try to search the web for “Syntax Highlighter”, “WordPress”, “Windows Live Writer”, and “Plugin” you will be presented with hundreds and hundreds of results. All of them talking about something that I couldn’t use, didn’t have, or didn’t want. I was really sad.

I came across a post by Rick Strahl covering some work he did on an Amazon book plugin for WLW using WPF and decided to rollup my sleeves and write my own. I mean think about it… writing a WLW plugin in WPF for a syntax highlighter that hasn’t been made yet (as far as I know anyway)… how cool is that!

So the next few posts will cover what I did to create the plugin and the issues that I ran into while creating it. And before I forget… I need to show of my plugin… The following code snippet was added using the plugin (of course) and shows one of the classes I created for the plugin. It is simply a name/value pair class that I use for the languages drop down list

public class SourceCodeLanguage
{
  private readonly string name;
  private readonly string value;

  public string Name
  {
    get { return name; }
  }

  public string Value
  {
    get { return value; }
  }

  public SourceCodeLanguage(string name, string value)
  {
    this.name = name;
    this.value = value;
  }
}

How cool is that? Well, maybe it isn’t something to write home about but… nah… it is. Currently the list of features this plugin has is really small. I really wanted to get it up and running and prove to myself that I could do it before getting into too many bells and whistles. Features:

  • Selectable indent size (2, 4, 6)
  • Changing the indent size re-formats the “code” sample
  • Selectable “code” language (e.g. C#, Ruby, Python, etc..)
  • All languages supported by WordPress.com are available
Advertisements
Standard

4 thoughts on “Windows Live Writer Plugin for WordPress.com [sourcecode] Highlighter

  1. Pingback: Windows Live Writer Plugin for WordPress.com [sourcecode …

  2. Pingback: WLW Plugin for WordPress.com - Part 1 « Refactoring… Me

Leave a Reply

Fill in your details below or click an icon to log in:

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