Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Code4Blog
Code4Blog

Code4Blog

Vitaly Zayko

|
8,434 installs
| (6) | Free
Saves any code from Visual Studio 2010 as HTML ready to be published in a Blog
Download

Code4Blog is a Visual Studio 2010 extension that allows to convert any code supported by Visual Studio IDE to HTML format with the same structure and colors. Main purpose of this extension is to prepare a code snippet to be published in rich documents, for example in blog posts, Microsoft Word documents or Help files. Some additional styling could be applied: max width and height of the code block, custom background (per code line), font family and font size, line numbering and others.

Code4Blog is now published onCodePlex. You are welcome to work with the source code directly!

How to use.

  • Install Code4Blog. Note: Visual Studio IDE should be closed before installation otherwise you will need to restart it. Both Visual Studio 2010 RTM and RC are supported.
  • Load a Solution and open a file from what code you want to export to HTML.
  • Either select a block of code to export this only part or select nothing in case you want to export the entire file. If you want to export just a part I suggest you to use block selection for better results. To do this put cursor at the beginning of block, press and hold SHIFT+ALT buttons and using either mouse or arrow buttons select exact block that should be exported.
  • Go to menu Tools and click on “Save Code as HTML”. Visual Studio will open new HTML window with content exported from code file.
  • If you want to use HTML sources (for example for a blog post): select HTML block from Source part of the window, copy it to Clipboard, open your favorite blogging tool or create empty blog post by browser, switch to HTML source mode and paste Clipboard content in a place it desire.
  • If you want to use this HTML in a Word document: select exported block from Design part of Window, copy it to Clipboard and paste in a Word document.

Additional styling.

You can apply some additional styling before export your code. To do this, go to menu Tools – Options. On the left part scroll down to “Code4Blog”. Here you can set maximum width and height (or leave it equal zero to make browser set it by default), background color for odd and even lines in Web format (meaning it should be a word, for example “Yellow” or hex number starting from #. For example #f4f4f4 set to light silver color) and other parameters. Then click OK and do re-export by clicking menu Tools – Save Code as HTML.

Code4Blog Options Page:

This snippet has been taken with following parameters: Width = 700, Odd lines color = #f4f4f4, Draw Border = Yes, Show Line Numbers = Yes:

1: /// <summary>
2: /// Default constructor of the package.
3: /// Inside this method you can place any initialization code that does not require 
4: /// any Visual Studio service because at this point the package object is created but 
5: /// not sited yet inside Visual Studio environment. The place to do all the other 
6: /// initialization is the Initialize method.
7: /// </summary>
8: public Code4BlogPackage()
9: {
10:     Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
11: }
12: 

Blog
You are welcome to read my tips and trick (mostly C#/.NET related) blog at http://zayko.net

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft