How to Add Syntax Highlighter(v3) to Blogger Blogs

How to Add Syntax Highlighter(v3) to Blogger Blogs

Syntax Highlighter version 3 is a powerful JavaScript tool to display and highlight your scripts and codes in blogger posts. In my previous post there is only a section for showing your codes. But in this tool we display in special section with highlighted script tags.

now i am showing a HTML Page Script here with this tool

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTML Code Example - way2blogging</title>
</head>
<body>
<h1>HTML Code Example</h1>

<p>Hello World !</p>

<p>This line is Sample line.</p>

<div class="foobar">
    This    is  an
    example of  smart
    tabs.
</div>

<p><a href="http://www.way2blogging.org/">Way2Blogging</a></p>
</body>
</html>

It is easy to setup and highly customized feathers you can use with this tool

  • Adding Scripts
  • Usage

Watch live – Demo for Themes Here

How to Install Syntax Highlighter in Blogger?

  1. Click the below Button
  2. First select a theme of your highlighter
  3. Select Brushes that you want to highlight (Ex:- JavaScript, HTML, PHP …)
  4. Click on “Generate” button to generate your code
  5. Copy the Entire code and paste it before </head> tag in your template

Generate Scripts

You successfully Installed Scripts on Blogger template!

Now How to Use this on Blogger Post

You want to display scripts and codes on blogger post

  1. Put your Script or Code inside the PRE tags and define class with brush name.

    <pre class='brush:[brushname];'>
    
    	<!--Put Your Code Here (must be HTML escaped)-->
    
    	</pre>
  2. Make sure your Script or Code must be HTML escaped, eg. all < must be replaced with &lt; This will ensure correct rendering. There are several tools to convert Your code !
    i. HTML Entities Encoder / Decoder
    ii. Encode / Decode HTML Entities
    iii. Postable
  3. For suppose i am showing a JavaScript code.

    i am defined a <pre></pre> tags, and defined a class <pre class=''></pre> and gave a brush name as <pre class='brush:js;'></pre>

  4. Then i paste converted code inside this tags
  5. finally my code is like

    <pre class='brush:js;'>
    	&lt;script type=&quot;text/javascript&quot;&gt;
    	var d = new Date();
    	var time = d.getHours();
    
    	if (time &lt; 10) {
    	document.write(&quot;&lt;b&gt;Good morning&lt;/b&gt;&quot;);
    	} else {
    	document.write(&quot;&lt;b&gt;Good day&lt;/b&gt;&quot;);
    	}
    	&lt;/script&gt;
    	</pre>
  6. it results like this

    	<script type="text/javascript">
    	var d = new Date();
    	var time = d.getHours();
    
    	if (time < 10) {
    	    document.write("<b>Good morning</b>");
    	} else {
    	    document.write("<b>Good day</b>");
    	}
    	</script>

If you have any Doubts, left a Comment below. :)




Do you Like this Article?

rss twitter facebook
Get Subscribe to Free Email Updates!!
*Your email address will not be shared with anyone.
  • eaa54ab3d434b860d98de1ea1db78df4delicious
Posted on March 2, 2011 • by Harish • in Blogger Widgets, Highlighters14 Comments

14 Comments on “How to Add Syntax Highlighter(v3) to Blogger BlogsAdd Comment

  1. Duy Pham March 4, 2011 5:23 am #

    Nice tip friend!

  2. puluth® April 6, 2011 4:09 am #

    thanks, you are my hero . :D

  3. Andika May 4, 2011 5:38 pm #

    Thanks. Good Article.

  4. Dhar May 26, 2011 6:59 am #

    Very thanks…

  5. Svip4u.InFo June 2, 2011 7:37 pm #

    Nice,but i want to change height of <pre>.
    What will you do?

  6. Packets June 25, 2011 10:38 am #

    Nice howto!

  7. Chandra January 30, 2012 11:26 pm #

    Nice post. I followed steps whatever you said above, but it was not working for my blog (recently created). can you kindly help me on this? I tried for cpp code syntax highlights.

    • Harish February 3, 2012 5:23 pm #

      Just Follow the Tutorial again.

  8. Kannan February 15, 2012 9:18 am #

    I followed the steps but not working for my newly created blog. Di I need to add any script on every pages ?

    • Harish February 15, 2012 9:58 am #

      Don’t need to add any other scripts. Once again follow the tutorial carefully

  9. Aditya Meilaz Rahmanto March 11, 2012 1:51 am #

    Nice Share Harish

  10. Ashish March 26, 2012 3:29 am #

    Hi
    I want to highlight some content of my blog post in the same way as you have highlighted your syntax.
    I am basically not interested in publishing syntax.
    Can you please help me out

    • Harish April 4, 2012 12:23 am #

      Use Syntax Highlighter for Blogger
      http://www.way2blogging.org/2011/03/how-to-add-syntax-highlighterv3-to.html

  11. WrRaThY April 13, 2012 3:09 pm #

    Thank you!
    i was trying to make it work for few hours now, with few different js plugins… with no luck.
    until i found ur page!

    Leave a Reply

     

    • Loading...
    © 2012 Way2blogging. Designed by , Powered by WordPress