Saturday 20 October 2007

Syntax Highlighter

I've just installed Google's Syntax Highlighter. This javascript allows you to highlight codes without formatting it manually.

To use, simply do

<pre name="code" class="language">
...some code here...
</pre>

A wiki of usage can be found here.

NOTE: One important thing to watch out for is opening triangular bracket <. It must be replaced with an HTML equivalent of < in all cases. Failure to do won't break the page, but might break the source code displayed.

Here's a list of supported languages and their aliases:

Language Aliases
C++ cpp, c, c++
C# c#, c-sharp, csharp
CSS css
Delphi delphi, pascal
Java java
Java Script js, jscript, javascript
PHP php
Python py, python
Ruby rb, ruby, rails, ror
Sql sql
VB vb, vb.net
XML/HTML xml, html, xhtml, xslt

No comments: