Friday, April 20, 2007

Recommended Tool: CopySourceAsHtml

Now that I am working on trying to put some usable information on this blog I need an easy way to transfer the code from the rich-text world of my ide to the html world of the browser. I remembered seeing a tool a while back for doing just that and thinking, "that's neat" only to return to whatever overwhelming concerns I had at the time. You never know when something you stumble over something, today it's a pointless novelty, tomorrow its a life-saver.

CopySourceAsHtml is sooooo easy. Simply select the text you wish to copy, as you've done a hundred-million times before, but this time you will select "Copy As HTML...". A dialog will display, take a moment to check out some of the options. Then just click 'OK' and the tool will perform some programming magic. POOF! When you paste your code will now be browser friendly html instead of plain old text.

It does a nice job of picking up the default settings of your ide and translating them to their HTML equivalent. If you want to be real slick, you can easily override many of your default settings in the options dialog. Experiment.


private const string SimpleMessage = "Frog's Brain";

 

/// <summary>

/// Write the simple message to the Console.

/// </summary>

public static void Simple()

{

    Console.Out.WriteLine( SimpleMessage );

}



Here're the changes I've made to make my code easier to read (and copy) in the browser.

  • Disabled "number lines" option.

  • Changed tab size from 4 to 8.

  • Changed font from Consolas to Courier New.

  • Increased font size from 8 to 10.

  • Enable "strip line breaks" option.

  • Enable "remove indentation" option.

  • Added CSS rules to "File Style" tab.

    border: solid 1px black; padding: 10px 10px 10px 10px; overflow: auto; white-space: nowrap;.

Submit this story to DotNetKicks

0comments: