Sha256: 95981f21209425423ea62b90357128cabe34ba3cf6fbaf59c2b138138c04c3c8
Contents?: true
Size: 876 Bytes
Versions: 9
Compression:
Stored size: 876 Bytes
Contents
begin require 'tidy' rescue LoadError puts "Tidy gem not available -- 'gem install tidy' to get it." end if defined? Tidy Tidy.path = ENV['TIDY_PATH'] if ENV['TIDY_PATH'] module Relevance module Tarantula class TidyHandler include Relevance::Tarantula def initialize(options = {}) @options = {:show_warnings=>true}.merge(options) end def handle(result) response = result.response return unless response.html? tidy = Tidy.open(@options) do |tidy| xml = tidy.clean(response.body) tidy end unless tidy.errors.blank? error_result = result.dup error_result.description = "Bad HTML (Tidy)" error_result.data = tidy.errors.inspect error_result end end end end end end
Version data entries
9 entries across 9 versions & 2 rubygems