Friday, August 17, 2007

I first used blogger. I then moved to wordpress. But I felt that blogger is better than wordpress. So now I came back to blogger with new vision and new goals.
But I thought, what to write first in my new blog. I got an idea, which is a solution for problem I faced when I am trying to post code in my blog. These things are gathered by searching through google for better answers.
I first tried to use CodePress & CodeEdit which are better solutions for browser based code editors. But then I found this Syntaxhighlighter project in code.google.com. It's a very good solution for me. I have found several posts from blogs like gpowered.blogspot.com. But these posts are somewhat out dated. So, this is the updated guide use http://code.google.com/p/syntaxhighlighter/ to post code in your blog.

  1. As the first task you must download the JavaScript Library from http://code.google.com/p/syntaxhighlighter/ site.
  2. Because blogger doesn't allow us to upload files we have to find a solution. My solution is to create a web page in pages.google.com and when you create google page you get free 100 MB online storage. Upload syntaxhighlighter source files to this account. You must upload most of the files in the library.(clipbord.swf, SyntaxHighlighter.css, shCore.js and other required brushes. You need a google account to create google pages)
  3. Then you have to add the required Javascript files and css file mentioned in syntaxhighlighter site to your template file in blogger account. Remember to add these code into head section of your template.
  4. And you have to modify the following code part mention in previously mentioned link:



    to this:


  5. Then you have to follow instructions in this link to post code in to your blog. You can use pre tags in Edit Html mode directly without replace '<' characters with any code like '&alt;'.

2 comments:

Jim Fricker said...

How can you be sure the window.onload event is not already being used by some blogger code?

Milinda Lakmal Pathirage said...

Sorry for the late reply. This thing work for me. But not sure about that mentioned situation.

Post a Comment