How to use SyntaxHighlighter
Posted in Rails, Ruby on Rails, SyntaxHighlighter, ror on July 23rd, 2007 by admin – Be the first to commentSyntaxHighlighter:
SyntaxHighlighter is a source code syntax highlighting plugin to help a developer/coder to post code snippets online with ease and and without having to worry about applying format. It is a free JavaScript tool for source code Syntex highlighting , It doesn’t care what you have on your server.
The idea behind SyntaxHighlighter is to allow insertion of colored code snippets on a web page without relying on any server side scripts.
WP-dp.SyntaxHighlighter supported languages:
- C#
- CSS
- C++
- VB & VB.NET
- Delphi, Pascal
- Java
- JavaScript
- PHP
- Python
- Ruby
- SQL
- XML, HTML, XSLT and any other XML style code
Click Here to download SyntaxHighlighter
http://syntaxhighlighter.googlecode.com/files/SyntaxHighlighter_1.5.0.zip
How to use SyntaxHighlighter
Place your code on the page and surround it with <pre> tag. Set name attribute to code and class attribute to one of the language aliases you wish to use.
<div class=”dp-highlighter“> </div>
<pre name=”code” class=”ruby” style=”display: none;“>
… some code here …
</pre>
An alternative to <pre> is to use <textarea> tag.
<textarea name=”code” class=”ruby”>
… some code here …
</textarea>
And You will get an output like