Saturday 24 September 2011

Adding syntax hilighter

First things first:
Installation and brushes.

This needs adding to the head of the blog html:
*Design -> Edit html -> under the "<head>" tag







Add this when you want to add code:
*You will need to switch to the HTML view when editing the post in order to add the "<pre>" tag
<pre class="brush: brush_name">
Your script here
</pre>
*brush_name can be js,perl,as3,etc. For a complete list see: brushes

UPDATE:


I recently installed syntaxhighlighter. The useful JavaScript tool for professional formatting of code blocks for blogs etc. by Alex Gorbatchev.
I followed the installation guide correctly adding the shCore.js and brush scripts I needed. I also included shCore.css and shThemeDefault.css style files, but I kept getting the same JavaScript error: XregExp not defined in shCore.js
It turns out after a lot of trial and error that you do not use the JavaScript files in the "/src/" folder of the download files. These do not work. You must use the 3 files with the same name in the "/scripts/" folder.
Just to clarify the 3 files are, shCore.js, shLegacy.js and shAutoloader.js

No comments:

Post a Comment