Code Syntax Highlighters for Webpages

There are lots of code syntax highlighters out there that help people write beautiful code text on the web. These are several examples of those that were encountered while building this blog:

  1. Prism
    Popular library by many bloggers. Needs both javascript file and stylesheet in case of usage.
  2. pygment
    Another popular library built with python that supports 300+ languages.
  3. highlight.js
    Supports 125+ languages and is continuously being managed.
  4. Google code-prettify
    The one currently used on this blog. Dead easy to use by simply including the javascript file hosted on a CDN.

Some simple examples by using code-prettify:

// literal notation
// creates: Object {foo: "fighters", daft: "punk"}
var objWithLiteral = {
    foo: "fighters",
    daft: "punk"
};

// constructor notation
// creates: Object {foo: "fighters", daft: "punk"}
var objWithConstructor = new Object();
objWithConstructor.foo = "fighters";
objWithConstructor.daft = "punk";
Open Comments