Code from http://sourceforge.net/projects/jade-plugins/