I use alexgorbatchev syntax highliter. It is a full guide to configure it for your blog. Sorry for my bad english.
How to create post with highlited code (Install CSS first):
It's ugly, but if you use Dynamic View in Blogger, you should add this code for each post in your blog (example for C++):
Blogger's strange behavior
It looks very strange, but you can add the code snippets (1) and (3) only at one page of your blog. It works for me and I do not understand how it works, but i dont need it. So, you can try, but I can't guarantee that it will works for you.
How to create your own configuration:
- Download this version of Syntax Highliter. Extract the arhive and find the script folder.
- Open the closure compiler website. (Note, I have some troubles with compiling new version, so I reccomend you download suggested version).
- Add the content of compiledScript to textfield on the left. (XML and Java are already added) I reccomend to use this version for people, who are not well at Javascript (like me), because you can easy debug your tactic by appending and deleting shBrush*.js.
- Add the content of shBrush[language].js file and append it in the textfield. Append it between 2nd and 3d "paragraph". The beginning of 3d paragraph looks like: (function(){function a(){this.regexList=[{regex:new XRegExp("(\\&l ...
- Repeat step 4. until all desired languages are added.
- Click the compile button. The compiled result is displayed on the right.
- On top there is a text "The code may also be accessed at default.js." right click and save the file under the link default.js
- Move the file to your webserver
- Create a new JS File and add
eval(function() { try { doHighlight(); } catch(e) { var elem = document.createElement('SCRIPT'); elem.src="[REPLACE ME]"; var theBody = document.getElementsByTagName('body')[0]; theBody.appendChild(elem); }
- Replace [REPLACE ME] with the url to the compiled that you just created
- Save the the file that you created in step 9 and move it to your webserver.
- Install CSS styles (see "How to install CSS")
- Paste your source code inside this PRE tag (like in paragraph "How to create post")
- Import your own loader at the final of your post;
How To Install CSS:
- To install the CSS styles, required by SyntaxHighlighter, you will need to do this step only once: open the Blogger's Advanced Layout Designer and access the CSS editor. Copy and paste the contents of the following files: