Thursday 31 March 2011

How to embed source code in BlogSpot


Step1: Go to your Dashboard/Design/Edit HTML.
Step2: Add the following codesnipet right before </body>
<link href='http://lockimage.googlepages.com/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://lockimage.googlepages.com/shCore.js'/>
<script language='javascript' src='http://lockimage.googlepages.com/shBrushCpp.js'/>
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>


Now it is ready to add source code to your post. It must be placed in <pre> tag. For example:
<pre name="code" class="Cpp">
...insert code here...
</pre>

Here is the result:

No comments:

Post a Comment