This website may use cookies. More info. That's Fine x
Welcome Login

Syntaxhighlighter


Syntaxhighlighter 3.0.83

To help a developer/coder to post code snippets online with ease and have it look pretty, you can use Syntaxhighter.  It is written in entirely on javascript.

syntaxhighlighter

Download library at: http://alexgorbatchev.com/SyntaxHighlighter/

 

Steps to add this library:

1. add css files: shCore.css, shThemeDefault.css

2. add js files: shCore.js and brush(s) files: eg: shBrushCSharp.js

3. enclose code that you want to highlight with <pre /> or <script /> method.  For <pre>, add attribute class="brush:csharp;..."

4. call SyntaxHighlighter.all() JavaScript method at end of web page

 

<pre> tag attributes:

to highlight line 2 and line 8, add: highlight: [2, 8]

to start from line 10, add: first-line: 10

Eg: to use csharp brush, and highlight line 8, enclose bit of code with:

<pre class="brush:csharp;first-line:10;"> code... </pre>

 

See config bit just before calling: SyntaxHighlighter.all()


Created on: Thursday, March 17, 2011 by Andrew Sin