Blogger Dynamic View does not directly supports SyntaxHighlighter. Therefore, we will have to do some work around to enable Syntax Highlighting in Blogger Dynamic View. In this post I will show you that how you can compile SyntaxHighlighter's JavaScript language brush files to make a single file that which will be used in all the posts in which you want to Syntax Highlighting. Following is the procedure with
1. Copy the code of following files onto Closure Compiler after one another.
shCore.js shBrushCpp.js shBrushJava.js shBrushCss.js shBrushJScript.js . . . So on2. Then copy following lins of code at the end.
function doHighlight()
{
SyntaxHighlighter.defaults["auto-links"]=false;
SyntaxHighlighter.defaults["quick-code"]=false;
SyntaxHighlighter.highlight()
}
doHighlight();
3. Press compile button. (Closure Compiler will genetrate a JavaScript file name as default.js)4. Download the default.js file.
5. Rename it to hightlight_.js and put this file onto your server in my case its Dropbox) and get the public link.
6. Then copy the public link of highlight_.js in highlighted line of following code.
eval
(
function()
{
try
{
doHighlight();
}
catch(e)
{
var elem = document.createElement('SCRIPT');
elem.src="https:[Dropbox URL]/highlight_.js";
var theBody = document.getElementsByTagName('body')[0];
theBody.appendChild(elem);
}
}
)
();
7. Save above function into a new JavaScript file and name it highlightLoader_.js8. highlightLoader_.js is the file that you would use in all of yours posts wherever you want to highlight the syntax of your code.
