Syntax Highlighting. Converting C# (et al) to HTML.

I’ve probably read a hundred or so posts of people looking for a way to syntax highlight source code listings in HTML. Maybe I’m the last to discover this site, but http://www.manoli.net/csharpformat/ is the answer for me so far. Just cut and paste some C#, VB, html/xml/aspx code int the text box and click "format my code" and voila! You get some clean HTML displaying nicely formatted code.

The tool allows you to optionally format the code with alternating line colors and line numbers if you so desire.

public class ThisIsSoCool
{
  ///      /// This is seriously neat.      ///      
  public void YouShouldTryThis()
  {}
}

Let’s try it with line numbers.

   1:  public class ThisIsAlsoCool
   2:  {
   3:    /// 
   4:    /// Look at me ma! I’m using line numbers
   5:    /// 
   6:    public void YouShouldTryThis()
   7:    {}
   8:  }

What others have said

Requesting Gravatar... Daniel Turini Jun 16, 2004 9:17 PM
# re: Syntax Highlighing. Converting C# (et all) to HTML.
I've been using on my blog the SnippetCompiler (http://www.sliver.com/dotnet/SnippetCompiler/), which have a cool feature "Export HTML to Clipboard". :)
Requesting Gravatar... pblah Mar 10, 2005 5:22 AM
# re: Syntax Highlighing. Converting C# (et al) to HTML.
dim obj as object

with obj
.first = "xx"
.last = "yy"
.id =2
end with

obj = nothing
Requesting Gravatar... you've been HAACKED Apr 27, 2007 5:22 AM
# Insert Code for Windows Live Writer
Insert Code for Windows Live Writer
Requesting Gravatar... Community Blogs Apr 27, 2007 5:37 AM
# Insert Code for Windows Live Writer
Several pople have asked me recently about the nice code syntax highlighting in my blog. For example:
Requesting Gravatar... me Aug 18, 2008 10:53 PM
# re: Syntax Highlighting. Converting C# (et al) to HTML.
Thanks for the link! I've been looking for something like this as well, and i love how it does SQL too!
Requesting Gravatar... HSH Nov 08, 2008 2:26 PM
# re: Syntax Highlighting. Converting C# (et al) to HTML.
is there format for CSS code? it's a lack
Requesting Gravatar... os Dec 06, 2008 7:26 PM
# re: Syntax Highlighting. Converting C# (et al) to HTML.
There is also a simple one that converts code to HTML that is directly pasted from Visual studio (www.dreamsys.gr/.../Code-Formatter-for-HTML.aspx)
Requesting Gravatar... Erik Rydeman Jan 31, 2009 11:27 PM
# re: Syntax Highlighting. Converting C# (et al) to HTML.
That's excellent! Just started a blog and was looking for something like that. :)

Cheers!

What do you have to say?

(will show your gravatar)
Please add 1 and 2 and type the answer here: