Posting code to your blog from Visual Studio

It is painful to post code to your blog without any special considerations. In the worst case you have to edit the resulting HTML yourself.

Working with Community Server gave me quite some pain here, so I looked around for some options that exist.

I found those methods:

  1. Copy from Visual Studio to Word 2007, remove TABs, remove hard-returns and replace with shift-returns. Mark as preformatted-html. Post the post to Community Server. Then open the Community Server built in editor and paste the code again in there. Painful. Does not work very well.
  2. Mike Stall suggests writing your own RTF to HTML converter: "Writing an RTF to HTML converter, posting code in blogs."
    http://blogs.msdn.com/jmstall/archive/2006/10/20/rtf_5F00_html.aspx
  3. A Visual Studio add-in that copies the source as HTML by Colin Coller: http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/
    listed in http://msdn.microsoft.com/msdnmag/issues/05/12/VisualStudioAddins/default.aspx.
    Read also: http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm_1.html or http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm.html
  4. A word macro that helps you with converting the code from Cory Smith: Format Code to HTML within a VS.NET 2K3 Macro (leveraging Microsoft Word)
    http://addressof.com/blog/archive/2004/10/06/966.aspx
  5. A JavaScript based formatter: http://www.dreamprojections.com/syntaxhighlighter/
  6. Use a CSS stylesheet that formats code for you of Jean-Claude Manoli: http://manoli.net/csharpformat/
  7. Further reading in the comments of Brad Adam's blog: http://blogs.msdn.com/brada/archive/2004/10/05/238427.aspx

     

I think the Visual Studio add-in solution is probably the most promising here.


Posted Apr 18 2007, 02:14 PM by Andreas Erben

Comments

Scott Munro wrote re: Posting code to your blog from Visual Studio
on 04-23-2007 16:52

This is something that I looked into a while ago... I didn't find much at all. Either the community has done some work since then... or you can google better than I can :)

Andreas Erben wrote re: Posting code to your blog from Visual Studio
on 05-02-2007 12:31

... or it is a combination of both :)

developers.de is a .Net Community Blog powered by daenet GmbH.