Saturday, May 26, 2007

How to use code highlighter in blogger?

Because the blogger will auto replace "\n" to "<br />", so maybe you will found your Code Syntax Highlighter should not work again, but it is easy to resolve this problem.

find the javascript file named "shCore.js", at the last few lines, you will found

highlighter.Highlight(element[propertyName]);

you need insert the next line before it:

element[propertyName] = element[propertyName].replace(/<br \/>/g,"\n");

it will reformat the data in your textarea before transform it to the highlighter.

No comments: