Archive

Posts Tagged ‘Ruby’

Free syntax highlighter written in Java Script

January 28th, 2009

So a while ago I had found a cool syntax highlighter that allowed you to make code look awesome on your website (as seen below, and elsewhere on this site). It worked great for a while, but with the release of Adobe Flash 10, there have been some major security enhancements that prevent data from being copied to the clipboard. 

With this new Flash update, my favorite part of this awesome library (copy & paste) has stopped working.  Since I had used the library for some time, and had done a decent amount of customization (included support for displaying PHP code) I refused to let my friend go quietly and have updated the syntax highlighter to work with the new Flash 10 plugin. The copy and paste feature (click “copy to clipboard”) is working again :)

Since I have had a few people ask me for a copy of this new library, I figured I would write up a little manual on how to use it as well. Enjoy!

Here is the original library:  http://code.google.com/p/syntaxhighlighter/
Here is my updated library:  http://blog.manifestinteractive.com/dl/sh.zip

My updated library uses one javascript file and supports syntax highlighting for C++, C#, CSS, Delphi, Java, JavaScript, PHP, Python, Ruby, SQL, VB, XML & HTML.

#1. ADD THIS TO YOUR HEAD TAG




#2. ADD THIS DIRECTLY ABOVE


#3. TO ADD STYLED CODE, ADD <pre> TAG AS SHOWN BELOW

<pre name="code" class="php">ADD YOUR CODE HERE</pre>

Available Class Styles:

LANGUAGE	CSS CLASSES (class='')
C++			cpp, c, c++
C#			c#, c-sharp, csharp
CSS			css
Delphi		delphi, pascal
Java		java
JavaScript	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

Web Development , , , , , , , , , , , ,