Mar 19, 2012

Add code to blogspot

How to add source code to the blogspot blog. Get your source code ready - then,

  • Go to http://www.chami.com/colorizer/ , select your language and paste your code in the box. 
  • Click on colorize button which gives three options to download the source. Select the third option partial HTML block. It will open the source code in web. 
  • Save that page ( or right click and view page source and copy the complete source. It will be starting with a pre tag)
  • Take the blog post compose and select the HTML view. Paste the code where you want to see the code and preview it. If everything is correct go to compose mode continue the post.
A tutorial of the same is given below

First in the compose mode create two lines like this
  •  
Then go to HTML mode you can see some thing like this

Add the code (partial html block obtained from colorize ) in between. So it will look something similar to this
Okie that is it. Go back to compose mode and preview. It will gives some thing like the following.


code comes here
#include <stdio.h>

int main ( void )
{
    printf ("Hello World\n");
    return 0;
}
code ends here.
For the outer border and the background replace <pre> with the following.

<pre style="border:1px solid lightgrey; background:#fafafa; color:blue;">
Edit the code snippet ( the stuff between code comes here and code ends here ) only through HTML view.

For Web Developer

  open -a "Google Chrome" --args --disable-web-security