Needs Improvement

Colin Coller's Blog
Posts: 10 | Comments: 68 | TrackBacks: ?

October 16, 2004

CopySourceAsHtml (Updated)

I've updated CopySourceAsHtml based on suggestions from Phil Haack and Eric Means, and on something Jake Good said about polluting his IDE. :)

Update: This version is no longer available for download. Download a newer version from this page.

After you install CopySourceAsHtml, two new commands will appear in the Options dialog under Environment > Keyboard:

and in the Customize dialog under Commands > Addins:

Copy ("Copy Source As HTML...") lets you select your language and formatting preferences before copying. CopyNow ("Copy Source As HTML") uses your previously selected preferences and copies immediately. If the active document's language isn't known, however, CopyNow simply calls Copy.

Copy ("Copy Source As HTML...") is added to the code window's context menu by default, but you can change which commands are added to the context menu in the registry (no editor, sorry) if you don't want to pollute your IDE:

HKEY_CURRENT_USER\Software\J.T. Leigh & Associates\CopySourceAsHtml\
    AddCopyToContextMenu
    AddCopyNowToContextMenu

If you find CopySourceAsHtml useful, find a bug, see room for improvement, or know of an existing add-in that provides the same functionality, please let me know.

Thanks,

Colin

06:45 PM | Colin

Comments

# RE: CopySourceAsHtml (Updated)

This tool rocks!

Btw, when I said that my IDE was polluted. It was my coworkers stating that.. yet the new feature you added in to alter the commands rocks!

Keep up the good work!

11:18 AM | Jake Good

# RE: CopySourceAsHtml (Updated)

I know it was your coworkers who said it, but your relating it is what made me think "Hmm, maybe they're right, does this really need to go on the context menu?" Thanks for the feedback!

12:39 PM | Colin

# RE: CopySourceAsHtml (Updated)

wow, yet another amazing addition to the already great IDE environment.

02:44 AM | Steve

# RE: CopySourceAsHtml (Updated)

Can you provide a VS.NET 2005 version???
Thanks

03:04 PM | Rob

# RE: CopySourceAsHtml (Updated)

Rob: I'll add it to my list of things to do.

05:54 PM | Colin

# RE: CopySourceAsHtml (Updated)

This is really cool, but its lacking one thing: its not using the CF_HTML format for the clipboard object. This means that you have to paste into an HTML editor, instead of being able to paste it into a rich editor such as Word or One Note. Check out http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp for some information on the CF_HTML format.

03:18 PM | Rick Lobrecht

# RE: CopySourceAsHtml (Updated)

Rick: Thanks for the pointer. I'll try to incorporate that in the next release.

08:47 AM | Colin

# RE: CopySourceAsHtml (Updated)

Hey,
Great work, I like muchly. Just a quick question/feature request. Any chance on adding an option to have it render inline styles instead of css classes? I only because on my blog host I can't insert a style block into my blog post, so i have to convert it all each time to inline styles to get it past :)

Other than that, well done.

--Geoff

08:37 AM | Geoff Appleby

# RE: CopySourceAsHtml (Updated)

I'm going to release a new version of the add-in this weekend. The new version will

- use VS.NET's syntax highlighter instead of a 3rd party highlighter (so it can highlight anything VS.NET can),
- use VS.NET's font and color preferences,
- generate either CSS classes or inline styles (for Geoff),
- generate either <p>'s (word wrap) or <pre>'s (no word wrap),
- generate an outer (add a border, background color, etc),
- copy HTML to the clipboard in text and CF_HTML clipboard formats.

It just needs a bit more testing before I subject others to it. :)

Colin

09:49 AM | Colin

# RE: CopySourceAsHtml (Updated)

Fantastic!

09:42 PM | Geoff Appleby

# RE: CopySourceAsHtml (Updated)

Colin, looking forward to this a lot! Any idea if this new code colouring methof will also preserve custom coloring like Resharpers ? Anyway, you're doing an awesome job, keep it up!

03:21 PM | Scott Galloway

# RE: CopySourceAsHtml (Updated)

Scott: Thanks! I'm not sure if it will preserve ReSharper's coloring or not. I might install it tonight to find out.

05:08 PM | Colin

# RE: CopySourceAsHtml (Updated)

I've released CopySourceAsHtml 1.2.0 here:

http://www.jtleigh.com/people/colin/blog/archives/2004/11/copysourceashtm_2.html

Colin

08:39 PM | Colin

# RE: CopySourceAsHtml (Updated)

Hi Colin.

This is a great tool - thanks!

Can I request an enhancement?

It would be really handy if the tool removed presceeding tabs so the pasted code ended up flush against the left border.

eg

public string foo()
{
return "bar";
}

became

public string foo()
{
return "bar";
}

Many thanks

Jonathan

03:19 AM | Jonathan Greensted

# RE: CopySourceAsHtml (Updated)

Jonathan: That's an excellent suggestion. I'll put it on the list and make sure it gets into the next version.

07:22 AM | Colin

# RE: CopySourceAsHtml (Updated)

Very helpful. Almost exactly was I was looking for! Now I just need to find one that doesn't depend on VS. Yours does a terrific job though. Thank you.

02:18 AM | Taylor Monacelli