Easy Way to Add Code Snippets in Blog Posts

syntax highlighting for blog posts


For the Novice Bloggers, syntax or code highlighting  is one of the hurdles to cross. But there is an easy way to do this, it takes only 10 seconds if you have your code ready for highlighting.

  1. Get your code ready to which you want to add highlighting.
  2. Go to hilite.me
  3. Paste your Code snippet in the source code field and don't forget to select the language of the code you are using
  4. Next step is selecting the style you want, I bet you will have a hard time in choosing one as they provide 19 different styles.
  5. You can preview your highlighted code below, when you are satisfied with the style copy the HTML code.
  6. Then come back to your blogger post editor, change the editor mode to HTML and paste the HTML code there
  7. Voila ! You have your code snippet highlighted beautifully.

syntax highlighting for blog posts


You can also try tohtml or Google-Code-Prettify as an alternative

This is the PHP Code snippet I highlighted, This code helps you in fetching IP Address

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function getRealIpAddr()  
{  
    if (!emptyempty($_SERVER['HTTP_CLIENT_IP']))  
    {  
        $ip=$_SERVER['HTTP_CLIENT_IP'];  
    }  
    elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))  
    //to check ip is pass from proxy  
    {  
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];  
    }  
    else  
    {  
        $ip=$_SERVER['REMOTE_ADDR'];  
    }  
    return $ip;  
}  

Labels: , , ,

Tech Ninja: Easy Way to Add Code Snippets in Blog Posts

Thursday, 12 December 2013

Easy Way to Add Code Snippets in Blog Posts

syntax highlighting for blog posts


For the Novice Bloggers, syntax or code highlighting  is one of the hurdles to cross. But there is an easy way to do this, it takes only 10 seconds if you have your code ready for highlighting.

  1. Get your code ready to which you want to add highlighting.
  2. Go to hilite.me
  3. Paste your Code snippet in the source code field and don't forget to select the language of the code you are using
  4. Next step is selecting the style you want, I bet you will have a hard time in choosing one as they provide 19 different styles.
  5. You can preview your highlighted code below, when you are satisfied with the style copy the HTML code.
  6. Then come back to your blogger post editor, change the editor mode to HTML and paste the HTML code there
  7. Voila ! You have your code snippet highlighted beautifully.

syntax highlighting for blog posts


You can also try tohtml or Google-Code-Prettify as an alternative

This is the PHP Code snippet I highlighted, This code helps you in fetching IP Address

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function getRealIpAddr()  
{  
    if (!emptyempty($_SERVER['HTTP_CLIENT_IP']))  
    {  
        $ip=$_SERVER['HTTP_CLIENT_IP'];  
    }  
    elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))  
    //to check ip is pass from proxy  
    {  
        $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];  
    }  
    else  
    {  
        $ip=$_SERVER['REMOTE_ADDR'];  
    }  
    return $ip;  
}  

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home