SyntaxHighlighter is an easy to use syntax highlighter for posting code snippets in blogs. Here are the steps to incorporate SyntaxHighlighter into Blogger:
- Go to the blog dashboard and select Layout for your blog.
- Choose Edit HTML.
- In the <head> section, paste in these two lines:
<link href='http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css' rel='stylesheet' type='text/css'/> <script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js'/>
- In addition, for each language that you intend to highlight, add lines to import the relevant JavaScript libraries. The full list of supported languages is here. Here's the example for XML:
<script language='javascript' src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js'/>
- Finally, right at the bottom before the </body> tag, add:
<script language='javascript'> dp.SyntaxHighlighter.BloggerMode(); dp.SyntaxHighlighter.HighlightAll('code'); </script>
- Save the blog template.
- Now, in blog posts, surround code sections with (replace the class with the appropriate language name):
<pre name="code" class="xml">...your code...</pre>
Comments
But I have a problem with FF 3.0.5
It doesn't load SyntaxHighlighter.css file content. IE and Opera works fine.
Can you help me?
I want to use Powershell highlighting but the Powershell file is not on http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/
How can this be accomplished?