June 29, 2011

Widgets

Add Syntax Highlighter To BlogSpot Blogs


SYNTAX-HIGHLIGHTERMost bloggers use the standard blockquote to share tutorials based on scripts and codes with their visitors but Alex Gorbatchev has created an amazing fully functional Highlighter that neatly displays web technologies such as HTML, CSS, JavaScript, Php, Python, Sql, xml etc. The codes are displayed line by line number wise. It also provides the user with options to Print the code, copy it to clip board or to see the code Source.

Alex has released the latest version (3.0.83) but we will use the old version (2.1.383) as it contains the options I mentioned above. Each code type comes with a script called Brush. I have used the most popular brushes as I mentioned earlier but if you wish to use a brush of your choice then you can select one from this Brush list.

Live Demo

How To Add Syntax Highlighter In Blogger?

The steps are more simple than you can imagine. I have tried to make the installation as easy as possible. Follow these steps,

  1. Go To Blogger > Design > Edit HTML
  2. Backup your template
  3. Search for this,

]]></b:skin>

     4.  And just below it paste the following code,

<!--SYNTAX HIGHLIGHTER BY MBT STARTS-->
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/2.1.382/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shYouBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushXml.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.382/scripts/shBrushPerl.js' type='text/javascript'/>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/2.1.382/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
</script>
<!--SYNTAX HIGHLIGHTER BY MBT ENDS-->

 

     5.   Save your template and you are done!

How it works?

Whenever you wish to share a code of any type with your readers, simply enclose the code between these lines,

<pre class="brush:css, brush:html, brush:js, brush:php, brush:sql, brush:python">

ADD THE PARSED CODE HERE

</pre>

I have combined all brushes into one making it easier for newbie to implement the tutorial.

Note: Do not add the code directly because you will get error in Blogger Editor, instead first parse the code using the Parser Tool provided by us.

Replace ADD THE PARSED CODE HERE with the parsed/encoded code and publish your post to the see the magic.

That's it! Hope you like it. I will publish different color schemes for Syntax Highlighter in my next posts so make sure you don't miss the update. I also published some block quotes with auto number list and if you wish you can use them instead by reading this tutorial,




If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you Subscribe to our regular Email Updates!

If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »

16 comments:

Jeet Dholakia on Jun 29, 2011, 10:16:00 AM said... #

Hello Mohammad,
i was waiting for this post.
excellent work brother.

Daus on Jun 29, 2011, 12:28:00 PM said... #

wow, there has alot of javascript.. confirm will make blog slower. i think better use pre code

Mohammad Mustafa Ahmedzai on Jun 29, 2011, 6:31:00 PM said... #

@jeet

Oh you are welcomed buddy. Make sure you don't miss a beautiful theme as I will publish it today. :d

@Daus
Not much daus. The scripts are stored at their servers and not the blog is responsible only for fetching data out of them.

Ravi Saive on Jun 29, 2011, 9:25:00 PM said... #

Am sure blg will slow down these javascritps

Govind Choudhary on Aug 9, 2011, 9:50:00 PM said... #

Really an awesum Post and your site too contains the Informative content. . . Waiting for this. . thnxxx a lot bro. . for sharing...Keep gng and Keep sharing :)

Malik on Nov 13, 2011, 2:58:00 PM said... #

very very nice tutorial friend
i used it in my blog, you can see it from here

http://internetricks4u.blogspot.com/

93blogger.com on Jun 30, 2012, 9:03:00 PM said... #

MashaAllah bro, very easy tutorial.. :)
Thanks

93blogger.com on Jun 30, 2012, 9:12:00 PM said... #

And one more thing Mohammad bro, can you please tell how to add a line above all code to tell reader how to copy code? Like
"To copy code click <> icon on right"
This you can see on bloggersentral website.
Please also add this in your tutorial.
Waiting :)
Thanks

Tanmay Kapse on Jun 30, 2012, 9:25:00 PM said... #

Very Cool !

http://www.yourpcgenie.blogspot.com

93blogger.com on Jun 30, 2012, 10:14:00 PM said... #

And one more thing bro, I have inserted this code without parsing it and it did not give any error.
I have also checked the current version of Syntax Highlighter from Alex's website, I think that's more cool and easy to use as the current version did not need flash to copy the code (as written by Alex).
Well, I am planning to implement the current version on one of my blogs, and I have also got how to add title to code :D..
Well thanks alot for this tutorial, I learned something new today :D..

technoclouds.blogspot.in on Aug 27, 2012, 10:28:00 PM said... #

nice tutorial...:)

Munna Haque on Sep 2, 2012, 10:54:00 AM said... #

Thanks and nice tutorial
All Pc Help

Nanang on Nov 2, 2012, 3:25:00 PM said... #

great tutor, i already using highlighter on my blog

Umais Bin Sajjad on Dec 31, 2012, 9:54:00 AM said... #

thank you very much for this tutorial.
My blog ••• http://developer-designer.blogspot.com

venkatareddy dodda on Feb 20, 2013, 5:42:00 PM said... #

it will not working in my blog

venkatareddy dodda on Feb 20, 2013, 5:56:00 PM said... #

where can i found parse tool

Click Here To add Comment

Confused? Feel free to ask

Your feedback is always appreciated. We will try to reply to your queries as soon as time allows.

Note:
1. To add HTML CODE in comments then please use our HTML Encoder
2. You can always Test the tutorial on our HTML Editor
3. No cheesy/spam Comments tolerated Spam comments will be deleted immediately upon our review.

Regards,
Mohammad

Support Us

If our Tutorials have helped you a little, then kindly spread our voice using the badge below:-

or try a Beautiful Banner


Widgets

 
  • MBT Icons and buttons

    Icons and Buttons

    Our resources have been successfully downloaded over 10K times and found almost every where. Get yours!

  • choosing webhost for a blog

    Why HostGator?

    Learn Why we chose HostGator as our Web Host and find discount coupons to kick start your blog today!

  • SEO Settings for blogger

    ALL IN ONE SEO PACK 2012

    Learn every single SEO tip that will boost your blog's ranking and organic traffic. We got them all!

  • Blogger widgets and plugins

    Visit MBT's Blogger LAB

    Why not take a tour of all great Blogger widgets published so far? You Name it we have it!

  • become a six figure blogger!

    Become a SIX FIGURE BLOGGER

    Learn what it takes to become a successful entrepreneur and build a living online!

About The Author

Hi! I am Mohammad, a certified SEO Consultant, Pro Blogger, Computer Engineer and an addicted Web Developer. Read More..

Recipes

SEO Affiliate Marketing Social Media

Make Money Online Web hosting

Blogging Tips Web Designing

Plugins and Widgets Blogging Ethics

Recent Comments

Popular Series

Powered by:

My Blogger Tricks © 2013. All Rights Reserved | Contact |