Friday, October 20, 2006

RTF to HTML converter - for posting code in blogs (via Mike Stall)

Mike Stall wrote a very nice and simple tool to convert RTF to HTML and easily post code in blogs.

It's a really cool tool, much simpler than anything other I could find. I had to make a few changes:

1. To complete escape formatting, you must add the following line at the beginning of the Escape method:

	st = st.Replace("&", "&amp");

2. I personally don't like having to go through a concrete file (Mike's code writes the result to an "out.html" file). I want the RTF data on the clipboard to be converted to HTML inside the clipboard. So instead of writing the converted data to a StreamWriter, I used a StringWriter and set the result to the clipboard:

using (StringWriter sw = new StringWriter())
Format(sw, data);

Et voila - now I define a shortcut on SlickRun to run this little utility easily, and I can now post formatted code in no time.

Thanks Mike!!!

No comments: