January 14, 2016

Adding Code in the Blog

Hi I was searching how to make the blog look more technical.
I have added a Syntax Highlighter JavaScript Library to the Blog Template.

It seems there are two ways of adding the code but I found this one to be the simplest one
I am checking this blog.
I have followed the steps as shown here
Using the tag "Pre" before the code
printf("Testing");
Though it prints in a different format, I wanted a proper coding background the way we see in the IDEs or other coding platforms. I wanted something like this which I got from a website that creates the HTML
  

1
2
3
4
5
6
int main

{
printf("Swagatha Ellarigoo");//testing
I am unable to use the option mention in the first link. SO kindly check the first link and modify the template accordingly, Or Please look out for the sites that give us a inbuilt options that we can use while blogging.
1
2
3
4
5
6
int main

{
printf("Swagatha Ellarigoo");//testing

} 
 
Below is the code that I entered using prettify.
main()
{

printf("Hello World");
/* Testing Comments */

}
So Finally I have one working solution. I used the prettify script and is working fine.
all we have to do is use
  <pre class ="prettyprint"> MY CODE HERE </PRE> "
It seems the language will be chosen automatically.The only criteria is to be in the HTML mode while adding the code and using the pre tags.

1 comment: