jQuery vanGogh

A jQuery syntax highlighter plugin powered by highlight.js

View the Project on GitHub mekwall/jquery-vangogh

Express your code in color

Why not let the legendary painter color your code? vanGogh is a small jQuery plugin that provides (client-side) syntax highlighting powered by the awesome highlight.js library.

Examples

Default configuration

This is the default look and behavior of vanGogh. You can highlight individual lines by clicking its line number, and even multiple lines by ctrl or shift clicking. Double-clicking the container will (if supported by the browser) select all code for easy copying.

Usage

$("pre").vanGogh();

Result

// Van Gogh; express your code in color
var setArray = function(elems) {
this.length = 0; // This is a comment
push.apply(this, elems);
return this;
}

var aString = "Hello world!";

Without gutter

If you don't want the gutter to show, just tell vanGogh to disable the numbers.

Usage

$("pre").vanGogh({ numbers: false });

Result

// Van Gogh; express your code in color
var setArray = function(elems) {
this.length = 0; // This is a comment
push.apply(this, elems);
return this;
}

var foo = "Hello world!";

Inline highlighting

vanGogh works out of the box for inline highlighting by skipping the pre element.

Usage

$("code").vanGogh();

Result

var foo = "Hello world!";

Horizontal scrolling

Just set a width of your pre container to enable horizontal scrolling.

Result

var foo = "This is a very long line that will allow you to horizontally scroll the container";

Test case

See test case on jsFiddle to see vanGogh in action!

Limitations

The highlight.js styles are not supported. vanGogh have additional elements that need styling so you will have to use vanGogh-specific styles.

Licensing

All code is open source and dual licensed under GPL and MIT.

Credits

Big creds to isagalaev and contributors for the creation of highlight.js; the heart and soul of this plugin.