Updated to correctly work within html documents as well.