:)
    Find out what I'm doing, Follow Me :)

Sunday, September 13, 2009

The Best Code Highlighter

Code highlighters are very useful tools to present code snippets on your blog or website with a professional look and improve the readability of code you provide for your readers. In this post I want to introduce you the best highlighter which I found.

The past two days I search in Google about code highlighters and I saw so much that I’ve got a headache.

I saw posts about:

• SyntaxHighlighter
• Quick Highlighter
• FV Code Highlighter
• Source Code Highlighter
• Highlight.js
• Etc.

There are so much highlighters but no one can’t highlight the source code in way what I want.

A good part of my posts contain source code snippets to illustrate and/or compliment the content. I’m a .NET developer and I write code in Visual Studio. In my posts when I show source code I want it to be formatted as in Visual Studio, with same colors and styles.
After two days research I found one. I think it’s the best one.

Windows Live Writer

You can download it from here.

The Writer Windows Live Gallery has a growing list of plugins. One of the useful is
Code Snippet plugin for Windows Live Writer.


But the most important to me is:

Paste from Visual Studio

It easily transfer syntax highlighted source code from Visual Studio to elegant HTML in Windows Live Writer.


You can find the plugin here.

If you have some troubles with installation on vspaste.msi file look this articles here and here.

I used Windows 7 beta and when I tried to install .msi file I had the error. But with “less msiérables” I could get the plug-in dll and then move it to “...\Program Files\Windows Live\Writer\Plugins”.

How does Paste from Visual Studio work ? Just copy the code from Visual Studio and insert it directly to Windows Live Writer.


The plug-in generates html and in browsers it is look exactly like code in Visual Studio.


public interface IChangeBoxedPoint
{
void ChangeProperties(int x, int y);
}

struct MyPoint : IChangeBoxedPoint
{
public int X { get; set; }
public int Y { get; set; }

public void ChangeProperties(int x, int y)
{
this.X = x;
this.Y = y;
}

public override string ToString()
{
string message = string.Format("X - {0}, Y - {1}", X, Y);
return message;
}
}


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestCaching._Default" %>
<%
@ OutputCache Duration="10" VaryByParam="none" Location="Client" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<
title></title>
</
head>
<
body>
<
form id="form" runat="server">
<
div>
<%=DateTime.Now %>
</div>
</
form>
</
body>
</
html>

The last that you can do is to delete author’s website link– It never shows up on the page, but it is on the bottom in the generated html.




This was a little disappointed to me, but the plug –in does it great job and the only one disadvantage is the hidden author’s link – which you can delete :)

6 comments:

  1. Why is the hidden author's link a disadvantage? I think the author deserves to have a little advertisment of himself, he has done a gread job, after all. You dou you have to delete the link, when it doesn't show up in the page?

    ReplyDelete
  2. I guess it’s OK wanting to get some links to his site, but to do it in such a way...
    And I guess that is very possibly the hidden link will be considered as some kind of black hat SEO and my blog's pages will be downgraded as a result.

    ReplyDelete
  3. OK, then make it visible, don't delete it. I can consider that a kind of piracy. Let's say I wrote a program and gave it away for free and anybody can use it, and I just want one simple thing in return - a little link that probably nobody would even notice. And then some people, who are using my program for free, think "Eh, what the heck, who cares about the author" and remove that link. Well, I can assure you that I won't feel good about it, and I'll think again whether or not to give away the next program I write for free.

    ReplyDelete
  4. Svetoslav Savov: In your example I will be one of the guys who will delete the author because I dont care about the author and this will not BE a piracy. If you create something you must distribute this software with license. In this license YOU HAVE TO POINT that the author "link/name/whatever you want" but THIS MUST EXIST IN THE License. If the author name is not mentioned in the license you have the right to REMOVE the author and use the application or to remove the author and even redistribute it.
    As always Microsoft SUCKS if you try to find what is the license of this plugin here http://gallery.live.com/liveItemDetail.aspx?li=d4409446-af7f-42ec-aa20-78aa5bac4748 you will see that only PRICE:Free is included :) WTF ? :)) Again the most important thing is missing THE license. Anyway after 10mins of searching reading the author blog and etc I found the official homepage of the plugin http://wlwplugincollection.codeplex.com and the license License: Microsoft Permissive License (Ms-PL) v1.1 Lol some awesome license :) I will no comment this anyway in the license text most parts are about redistribution and using parts of the code. Removing the author name from the output of the application is not mentioned so removing it IS NOT piracy :)

    ReplyDelete