Saturday, April 24, 2010

Migrating to syntaxhighlighter 2.1.x

Problem:
I recently decided to upgrade to syntaxhighlighter 2.1 from 2.0 on my blogger blog. I thought it was going to be as easy as dropping in a new version. I was wrong, the TEXTAREA in which i was putting my code is no longer supported. instead SCRIPT tags are used to enclose the code! AHHH! I have about 40 code snippets on my blog and conversion seems very not-fun.

Solution:
I started to hand convert some of the entries, to find that the new blogger post editor was also losing all of my tabs! This was going to be painful to do by hand..
Alas, i decided to try to do it with javascript, and it worked!

I pulled in the latest jquery into my template to ease the pain. Instead of the regular synataxhighlighter init i now have this:



Now, i dont need to hand convert all of my textareas to the new format, and the tabs are saved. Good deal!

No comments:

Post a Comment