- Open your blog at blogger.com. Login if requested and select/click on your blog name.
- Go to template -> Edit HTML -> Proceed
- Find (CTRL+F) the </html> tag and just before it copy and paste this section of code:
- Save your template
<!--SYNTAX HIGHLIGHTER BEGINS--> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script> <script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf'; SyntaxHighlighter.all(); </script> <!--SYNTAX HIGHLIGHTER ENDS-->
Now any post is ready to use highlighted code. There are two ways to do this: using pre or script tags.
Using <pre> tag:
- Open the post you want to edit or create a new one.
- Go to Posts and select one post clicking on Edit or click on New Post button.
- Select the HTML view and find the section of code to highlight.
- Insert this code before the section of code:
<pre class="brush: html">
- Insert this code at the end of the code:
</pre>
Using <script> tag:
- Open the post you want to edit or create a new one.
- Go to Posts and select one post clicking on Edit or click on New Post button.
- Select the HTML view and find the section of code to highlight.
- Insert this code before the section of code:
<script type="syntaxhighlighter" class="brush:html"><![CDATA[
- Insert this code at the end of the code:
] ]></script>
The possible changes to the headers are:
- Change the theme. The list of themes is here, you just need to replace one css theme by other. For example, replace the default theme (shThemeDefault.css) by RDark theme (shThemeRDark.css).
- Remove brushes you will not need or add brushes not included. For example, I replace the VB brush (shBrushVb.js) by the Bash brush (shBrushBash.js) and remove others like C# (shBrushCSharp.js) and Java (shBrushJava.js).
The possible changes to the <pre> and <script> tags are:
- Change the brush type according to the code type. The different brushes are here.
- Remove the numbers for each line adding "gutter: false;" inside the class. For example:
<pre class="brush: html; gutter: false;"> HTML Code </pre>
For more information check out the sources below.