In this tutorial you will learn how to add syntax highlighter on your blog on Google blogger. In order to the add the Syntax highlighter scripts and make it work on your blog follow the steps.
1. First, take backup of your current blogger template or try with sample template.
2. Navigate to Edit HTML mode.
3. Copy syntax highlighter css code from below location
4. Copy and Paste the code above </b:skin>
5. Copy paste the below given code before </head> tag in your template
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js' type='text/javascript'/>
NOTE: Here, You don't need all that brushes , just keep what you really need.
6. Copy Paste the below given code before tag.
<script language='javascript'>
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
7. Now click the save button to save all the changes you have made to your blogger template.
8. Now lets proceed, how to use it in your posts:
How to write source codes in pre-tag?, well, you need to do is just invoke the classes in pre tag.
For example, you might wants to java code, you should do this:
Some examples of codes in my Blog:
Examples:
Below is a comparison of a snippet of java code with standard and syntax highlighting :
Standard rendering
/*
Java Hello World example.
*/
public class HelloJava
{
public static void main(String args[])
{
/*
Use System.out.println() to print on console.
*/
System.out.println("Welcome to Java!");
}
}
Syntax highlighting
public class HelloJava
{
public static void main(String args[])
{
/*
Use System.out.println() to print on console.
*/
System.out.println("Welcome to Java!");
}
}
Conclusion
So, this was all about How to install SyntaxHighlighter in Blogs. If you have any type of queries regarding this tutorial please feel free do let us know, We will try our best to resolve them. If you like this tutorial and find this useful and meaningful then please don’t forget to share this with your friends and social media too.