Improve speed of applying smartypants by 3x.

rubypants.rb has also been refactored to be easier to understand and extend.