Code highlighting

Thursday, March 04, 2010

Highlighting your code on Blogger

A couple of people have now asked me for the tool that I use for pasting the source code on my blog.
In order to use the same, you will have to change the template of your blog and include the following scrips:


<script src='http://amalafe.googlecode.com/svn/trunk/Scripts/shCore.js' type='text/javascript'/>
<script src='http://amalafe.googlecode.com/svn/trunk/Scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://amalafe.googlecode.com/svn/trunk/Scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://amalafe.googlecode.com/svn/trunk/Scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://amalafe.googlecode.com/svn/trunk/Scripts/shBrushXml.js' type='text/javascript'/>
<link href='http://amalafe.googlecode.com/svn/trunk/Styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://amalafe.googlecode.com/svn/trunk/Styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script type='text/javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://amalafe.googlecode.com/svn/trunk/Scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>


After that, you will be able to create code by specifying the following:

<pre class="brush: c-sharp;">
Your code goes here...
</pre>

6 comments:

  1. Too bad this work properly in browsers like Google Chrome

    ReplyDelete
  2. Does not work properly on Chrome?
    I actually only use IE, so have never tried to open it in any other browser. But I will give it a show tonight.
    Thanks for pointing that out

    ReplyDelete
  3. Hi Vanya
    Seems only IE and Opera supports these scripts.
    Chrome, Safari and Firefox does brush up the code.

    ReplyDelete
  4. Hello! I have a xpo project which make the html passing direct from x++ but I do not know if I'm allowed to post links here.

    ReplyDelete
  5. Yeah, feel free to post a link here.
    thanks

    ReplyDelete
  6. http://www.dynamicslookup.ro/en/customize/8-code-highlight.html All the x++ code on my site is posted with this tool.

    ReplyDelete

Please don't forget to leave your contact details if you expect a reply from me. Thank you