Showing posts with label AutoFormatter. Show all posts
Showing posts with label AutoFormatter. Show all posts

Wednesday, September 26, 2007

Visual Studio 2005 Automation Samples

Guess I should have looked at creating a Visual Studio plugin first rather than figuring out how to convert RTF to HTML. I might not need to do that judging by the description of one of the Visual Studio 2005 Automation Samples:

Generate HTML
This sample demonstrates how to take text from the editor window and build a HTML file using this text, including font and color syntax highlighting information.

Haven't downloaded this yet, but I will do. Sounds like the Blogger code upload plugin could be quite easy to implement.

I found this page linked from the Customize and Extend Visual Studio page on MSDN.

UPDATE: Ahh, the Generate HTML sample is actually in C++, not C#. Should still be able to use it as a guide though, just need to figure out what objects to use.

Tuesday, September 25, 2007

RTF to HTML and the GData API

Finally got around to properly extracting the RTF conversion code from AutoFormatter last night. It turned out to be as easy as I thought, after last time's wasted efforts. I've had a look on Robert Verpalen's blog for some contact details, but I can't find any and the AutoFormatter post doesn't seem to allow comments.

I might have to leave a comment on another one of his other posts, but the date on the AutoFormatter post is December 2005, so I don't know if he's maintaining it now. Doesn't seem to be any posts since then about the application anyway.

I think I'll wait until I have something usable first though.

Anyway, with that extracted I downloaded the GData API SDK and tried to connect to my blog. The sample code included is very helpful, but it still took a little time to get my head around. I eventually knocked up some code that would add a new draft to my blog, so I think I have everything I need to make the plugin now.

Now I just need to learn about how to make a decent plugin.

Friday, September 21, 2007

Trying to Extract Features from AutoFormatter

I took a look at the AutoFormatter code last night, and tried to make a start on extracting the code that does the conversion into a class library.

I can't say it was an easy task though, and at the end of it all I found I'd done it wrong anyway. What I really need is a class that just converts RTF to HTML, but I had extracted the method that creates the div blocks around the code as well. Surrounding the code in this way does make the end result nice and pretty, but for the purposes of a generic conversion library it's not needed.

It was about 11 o'clock last night when I figured this out. It's always a little disheartening when you find you've just spent the last 3 hours doing something that you now need to discard.

Guess that's what happens when you try to modify code without truely understanding it. I can't see any unit tests in the code to give an indication of the intention of some of the code, or to provide a safety net to the quite severe refactoring that I am attempting.

But I think extracting the RTF to HTML code should be easier than what I did last night. There were a number of options I needed to extract into a class and pass into the method last night, but I'm sure I don't need all of this for the straight conversion.

I'll see how it goes.

Wednesday, September 19, 2007

RTF to HTML: AutoFormatter 2.0

Visual Studio copies code from the editor in RTF format, so technically all you need to do is convert RTF to HTML in order to upload it to a blog post, which will form part of the plugin, if I ever get around to making it.

Looking around last night I found AutoFormatter 2.0. This is a .Net 2.0 application written in C# that does a neat job of doing exactly what I need. The HTML it produces is in a scrolling DIV, formatted in Visual Studio colours, and looks quite nice.

In fact, as a standalone application this is just what I need to post code samples, but I started down this path to try the GData API with a Visual Studio plugin. I'm hoping to use part of AutoFormatter to do it though.

If I can extract the conversion code from the AutoFormatter app into a standalone assembly, then theoretically I should be able to use it from the plugin. The code is available for download, and I made a start at extracting the required elements last night. If I can get this working then that's a big chunk of the work done I think.

I'll get in touch with AutoFormatter's author if I manage to get the core functionality extracted to a separate assembly. Hope he doesn't mind.