Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Generating Marked-up code snippets in my blog

In a recent comment - http://weblogs.asp.net/dneimke/archive/2004/04/09/110222.aspx#112468 - Brian asks how I do my colorization of code snippets in my blog.

I recently wrote this entry describing how I use my MarkUp component ( which is freely available ) to emit stylized code snippets.  The component also emits a Css stylesheet for rendering the code:

    http://weblogs.asp.net/dneimke/archive/2004/02/03/66621.aspx

My current Css block for a code window looks like this:

PRE.CodeSnippet
{
    background-color: #f0f0f0;
    padding  : 1em;
    margin  : 0px 2em;
    padding  : 1em;
    border  : 1px dotted gray;
    font-family         : "Lucida Console";
    font-size           : 1em ;
    width               : 800 ;
    color  : #000000;
    overflow            :auto;
}


And here is the Css block for a command line window:

PRE.Console
{
    background-color: #000000; 
    color: #00ff00;
}

So, to create a normal code snippet, you simply run your snippet through the tool and whack it inside a PRE tag with the "CodeSnippet" class applied to it.  To create a console window you whack your text inside a PRE tag with both the "CodeSnippet" and "Console" classes applied.


Note: To grab the MarkUp tool, go to http://Workspaces.gotdotnet.com/MarkUp and download the binaries labelled: "SimpleMarkUpTool 1.0.0.0 - Binaries Only "

No Comments