Thursday, July 23, 2009

Blogging Tip #2

People who are used to Visual Studio IDE 2005 / 2008 are accustomed to seeing code snippets with colors to identify different constructs like class, interface, access specifiers, keywords etc etc. Sites like MSDN, code project, code plex etc show similar code snippets which are identical to that of visual studio color schemes.

This feature of visual studio makes it easier to understand different code constructs. The problem arises when some one like me tries to insert code snippets in the blog entries that I write. The blog service I use for my blogs is Blogger. If I copy the code from Visual Studio and paste it in my blog editor, all the formatting is gone for a toss. You see multiple line breaks when you are expecting a single line break between two lines. The indentation is not proper. The braces don't match properly etc. etc.

Ideally I would like to retain the visual studio formatting so that when I paste text blocks from source code window to the blog editor, it resembles the same. Fortunately there are few addins available on the net which can be used to copy source code from visual studio code editor as a HTML text rather than plain text. My sincere thanks to the people who developed such addin to help others.

Following are some of the source code addins available on the net.

Copy Source As HTML (CSAH)

Paste from Visual Studio

 

Here is an example of source code copied with the help of Copy Source As HTML Addin.

public class TestClass

    {

        /// <summary>

        /// Constructor

        /// </summary>

        public TestClass()

        {

            Console.WriteLine("Hello World");

        }

    }

 

 

Hope this helps.

No comments:

Post a Comment

Submit Apache Spark job from Command Line to HDInsight cluster

Background This is the 3rd part of the Step by Step guide to run Apache Spark on HDInsight cluster. The first part was about provisioning t...