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:
- 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.
- 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
- 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
- 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
- A JavaScript based formatter: http://www.dreamprojections.com/syntaxhighlighter/
- Use a CSS stylesheet that formats code for you of Jean-Claude Manoli: http://manoli.net/csharpformat/
I think the Visual Studio add-in solution is probably the most promising here.
Posted
Apr 18 2007, 02:14 PM
by
Andreas Erben