Copy As HTML
This is a lightweight tool that allows you to copy code from the Code Window and convert it into HTML while preserving syntax highlighting, indentation, background colour and font face.
- using System;
- using System.Windows.Forms;
- using System.Drawing;
- namespace WindowsFormsApplication1
- /// <summary>
- /// Class summary.
- /// </summary>
- public partial class Form1 : Form
- /// <summary>
- /// Constructor summary.
- /// </summary>
- public Form1()
To copy code in HTML format:
- In the Code Window, highlight the code that you want to copy.
- Select the options you want in the tool window.
- Click on "Copy As HTML".
- Optionally click "Save As Defaults" so that the extension remembers them.
The code will then be copied to the Clipboard in two formats: HTML format and text format. These two formats
cater for the two views you typically get in a blog editor: WYSIWYG view and HTML code view. Note: You can
also access the command from the Menubar –> Tools –> Copy As HTML.
The tool window can be accessed from the Menubar –> View –> Other Windows –> Copy As HTML
- Max Height
- Title Block
- Alternating Lines
- Line Numbers
- Wrap Lines
- Background Colour
Copy As HTML Source
- HTML Encode. Converts the HTML source code to encoded HTML.
- Syntax Highlighting. Applies full syntax highlighting to the HTML-encoded HTML source code.
Use Class Names
Your custom colours are left intact because it converts the RTF, outputted by Visual Studio, into HTML.
Line numbering is produced by making use of HTML ordered list; this produces far more efficient HTML code than
span tags cluttering up your webpage. This approach requires co-operation from the accompanying style sheet. The
example below assumes the default class name is being used:
Also, empty span tags are removed; something that many RTF to HTML converters leave behind in the conversion
||10 Nov 2022
||Improved parsing of Python multiline statments.
Improved performance of regular expressions.
Added option for auto line numbers.
||25 Oct 2022
||Upgraded to Visual Studio 2019 using an AsyncToolWindow.
||9 Apr 2015
Re-enabled the option to choose the background colour because it now uses an improved algorithm to
obtain the background colour set in Visual Studio.
||11 Mar 2015
Updated installer for VS2013.
Added functionality to preserve font family. Defaults to
Improved option Copy As HTML Source with Syntax Highlighting.
character to  .
Disabled the option to choose the background colour because it now uses
the background colour set in Visual Studio.
||24 May 2013
||Updated installer for VS2012.
||9 Aug 2011
||Added start line number.
Improved Unicode conversion.
||13 May 2011
||Updated MSI for VS2010.
||19 Dec 2009
||Added support for negative Unicode characters in the RTF.
||26 Oct 2009
Added the control to more context menus to support the following file types: .asax (VB), .asax (C#),
.ashx, .asmx, .css, .js, .wsf, .xaml
||12 Oct 2009
Outputs quotation marks as named HTML character entities to prevent some blog editors from
converting straight quotes to smart quotes.
Copy As HTML Source: Uses HTML Encode instead of
replacing angle brackets.
||24 Sep 2009
||Corrected line number margin for code snippets with less than ten lines of code.
||23 Sep 2009
Added control to context menus for ASPX, ASP and HTML windows.
Added option: Copy As HTML
Added option: Use Class Names.
Changed to ems for line number margin to allow for
variable font sizes.
||16 Sep 2009