class Sanitize

def clean!(html)

made.
Performs clean in place, returning _html_, or +nil+ if no changes were
def clean!(html)
  @whitelist_nodes = []
  fragment = Nokogiri::HTML::DocumentFragment.parse(html)
  clean_node!(fragment)
  @whitelist_nodes = []
  output_method_params = {:encoding => 'utf-8', :indent => 0}
  if @config[:output] == :xhtml
    output_method = fragment.method(:to_xhtml)
    output_method_params[:save_with] = Nokogiri::XML::Node::SaveOptions::AS_XHTML
  elsif @config[:output] == :html
    output_method = fragment.method(:to_html)
  else
    raise Error, "unsupported output format: #{@config[:output]}"
  end
  result = output_method.call(output_method_params)
  # Ensure that the result is always a UTF-8 string in Ruby 1.9, no matter
  # what. Nokogiri seems to return empty strings as ASCII for some reason.
  result.force_encoding('utf-8') if RUBY_VERSION >= '1.9'
  return result == html ? nil : html[0, html.length] = result
end