Pretty syntax highlightning for online code snippets

11/11/2010 6:14:55 PM

Highlight keywords and display code on the web.

Finally added some support for formatet code snippets on this site by using Prettify and some CSS.

Prettify is here,
http://code.google.com/p/google-code-prettify/

The styles for a nice scrolling code window,

pre   {   font-size: 12px;   padding: 0;   margin: 0;   background: #f0f0f0;   line-height: 20px; /--Height of each line of code--/   background: url(/Content/Img/codebg.png) repeat-y left top; /--Background of lined paper--/   width: 600px;   overflow: auto; /--If the Code exceeds the width, a scrolling is available--/   overflow-Y: hidden;  /--Hides vertical scroll created by IE--/  }  pre code   {   margin: 0 0 0 40px;  /--Left Margin--/   padding: 18px 0;   display: block;  }  

and to use it, just add the code snippets like this

  int i = 0;  int x = 5 / i;  

Works alright with TinyMCE editor (which is used by N2CMS).