Strange Symphonies Don’t worry, be happy

8Jun/070

Aizatto’s SyntaxHiglighter Released

Update: This plugin has been discontinued, I would recommend you use SyntaxHighlighter Evolved

Note: This is a WordPress plugin to highlight source code, and is based off SyntaxHighlighter by Erik Range.

I found the need to rewrite Erik Range's SyntaxHighlighter to suit my needs. More importantly, to save bandwidth and only load required JavaScript files. Similarly I thought I could compress the CSS and JavaScript, trim them down to save even more bandwidth.

Fixed some short comings (such as not working in WordPress Multiuser).

I am aware of the Geshi Syntax Highlighter library. But I was having so much fun coding this, that time flew by and I completed most of it. So I thought I'd at least post this up for others.

Features:

  • Cleaner Codebase
  • No need to specify which languages you want to load
  • Saves bandwidth
    • Loads only the required files depending on the content
    • Uses optimized versions of the CSS and JavaScript
  • Uses the latest version (1.5.0) of the SyntaxHighlighter JavaScript libraries.
  • Option to use a different path for the location of the CSS and JavaScript files, allowing you to cache them.
  • Works in WordPress Multiuser
  • Source code looks better in feeds, and don't look broken
  • Ability to specify a local set of options for the code snippet
  • Specify what line number the first line is

Supported Languages

C, C++, C#, Java, JavaScript, Pascal, PHP, Ruby, SQL, VisualBasic, VisualBasic.net, XML, HTML, XHTML

This is limited to the number of language SyntaxHighlighter supports.

How to Use

In Ruby:
Entering:
[source:ruby]puts "Hello World"[/source]
Gives us:

puts "Hello World"

Entering:
[source:ruby firstline=10 hidegutter hidecontrols]puts "Hello World"[/source]
puts "Hello World"

Entering:
[source:ruby firstline=21 gutter columns]puts "Hello World"[/source]

puts "Hello World"

Entering:
[source:ruby collapse]puts "Hello World"[/source]

puts "Hello World"

Samples:

For better samples see my various blog posts:

Requirements

None that I know off.

Download

http://src.aizatto.com/syntax_v0.1.zip

Installation

Dump the syntax folder into the plugins folder.

License

GNU Public License Version 2

Others

If you have any comments, suggestions, or bugs. Don't hesitate to contact me. If you would like to test beta release of this plugin, do contact me!

Known Bugs:

  • By default, certain WordPress installations will use the "Visual Rich Editor" which WILL SCREW with the formatting of the source.

Certain CSS will break. Like so:
Actual:
.float-right { float: right; }
Formatted:

.float-right { float: right; }

This is a problem with the SyntaxHighlighter JavaScript library.

Related posts

Tags

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.