A jQuery syntax highlighter plugin powered by highlight.js
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.
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.
$("pre").vanGogh();
// 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!";
If you don't want the gutter to show, just tell vanGogh to disable the numbers.
$("pre").vanGogh({ numbers: false });
// 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!";
vanGogh works out of the box for inline highlighting by skipping the pre
element.
$("code").vanGogh();
var foo = "Hello world!";
Just set a width of your pre
container to enable horizontal scrolling.
var foo = "This is a very long line that will allow you to horizontally scroll the container";
See test case on jsFiddle to see vanGogh in action!
The highlight.js styles are not supported. vanGogh have additional elements that need styling so you will have to use vanGogh-specific styles.
All code is open source and dual licensed under GPL and MIT.
Big creds to isagalaev and contributors for the creation of highlight.js; the heart and soul of this plugin.