Visual Studio add-in: CopySourceAsHTML

When I started with this blog I needed some tool to copy code snippets from Visual Studio to Windows Live Writer so I get formatted code. There is cool online code highlighter called GeSHi, but I wanted my code to look like in Visual Studio editor. After some searching I found Visual Studio add-in CopySourceAsHTML.

CopySourceAsHTMLAfter installing this add-in you can see new selection in code editor’s context menu: Copy As HTML… When you click on this menu then the following dialog with copy options will be opened.

CopySourceAsHTML

As you can see there are many so much options that these options are put on separated pages. When you paste code to Live Writer make sure you use Paste Special option. There you can say that you want to paste the code with formatting.

Here you can see cooperation between Visual Studio, CopySourceAsHTML and Windows Live Writer (horizontal bars are added by me).

public new void RaiseCallbackEvent(string eventArg)

{

    if (eventArgument.StartsWith("searchFieldChangedTo:"))

    {

        searchField = eventArg.Replace("searchField:", "");

        return;

    }

    else

    {

        var multiVal = new SPFieldMultiColumnValue(eventArg);

        if (multiVal.Count == 3)

        {

            searchOperator = multiVal[0];

            eventArg = eventArg.Replace(";#"+searchOperator, "");

            base.RaiseCallbackEvent(eventArg);

        }

        else

            base.RaiseCallbackEvent(eventArg);

    }

}

2009-08-06 Update Source of CopySourceAsHTML is now available in CodePlex.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    5 thoughts on “Visual Studio add-in: CopySourceAsHTML

    • February 9, 2009 at 4:46 pm
      Permalink

      That’s odd. I’ve been using CopySourceAsHTML (I even added a button to my toolbar for it) but your image shows a different layout (Wrap lines instead of Wrap words) and an extra check box (Include RTF). I downloaded the latest (version 3.0.0) and the differences are still there.

    • February 9, 2009 at 7:48 pm
      Permalink

      I don’t have 3.0.0 yet. It should be a little bit older version.

    • October 23, 2009 at 10:10 am
      Permalink

      To begin with, they are very small indeed. ,

    • Pingback:Making CopySourceAsHtml add-on work with VS2010 | Gunnar Peipman - Programming Blog

    • April 20, 2025 at 7:11 pm
      Permalink

      This piece of writing gives clear idea in support of the new
      viewers of blogging, that in fact how to do blogging
      and site-building.

    Leave a Reply

    Your email address will not be published. Required fields are marked *