Home » Code »

apache_prettify

Nick Nettleton | 24 April 2009 | Comment |

apache_prettify adds code colouring and line numbers to Apache configuration code - the stuff you write in httpd.conf and .htaccess. Most useful if you are publishing this sort of code in your blog.

  • Written in JavaScript - works in the browser
  • Dead easy to use
  • Compatible with all JS libraries - jQuery, prototype, etc
  • Quick - just a couple of regexs
  • Lightweight - 1.35K minified
  • To change the appearance, just edit apache_prettify.css

Demo:

Click here to see it in action

Usage:

apache_prettify has just two functions: a 'quick fix' one and a fine-grained control:

// prettifies all matching tags - you'd probably use 'pre' or 'code' in here
apache_prettify_all('tagname')

// prettifies an individual element
apache_prettify(element)

Download:

Download apache_prettify-0.1a.zip

Notes and todos

  • Need to test on Mac & FF3
  • Some IE display bugs. Yargh.
  • Add a 'guessing' function, to automatically identify Apache config code and highlight that
  • Tie in wih prettify.js


Topics: Apache Javascript

Comments