Nokogiri branch rebased

Here's a cleaner pull request for the Hpricot => Nokogiri replacement.

Coming from https://github.com/discourse/discourse/pull/138