Sha256: 30ff73d628ad3f74f16c7262789e3c1f47a68953a7e2d46f417635e539080f1c
Contents?: true
Size: 961 Bytes
Versions: 6
Compression:
Stored size: 961 Bytes
Contents
#!/usr/bin/env ruby require 'rbconfig' require 'tidy' require 'nokogiri' require 'strelka/cms/pagefilter' unless defined?( Strelka::CMS::PageFilter ) # A filter that cleans up broken HTML using libtidy. class Strelka::CMS::PageFilter::Cleanup < Strelka::CMS::PageFilter # Options to pass to libtidy TIDY_OPTIONS = { :show_warnings => true, :indent => true, :indent_attributes => false, :indent_spaces => 4, :vertical_space => true, :tab_size => 4, :wrap_attributes => true, :wrap => 100, :output_xhtml => true, :char_encoding => 'utf8' } ### Process the +page+'s source with the filter and return the altered content. def process( source, page ) Tidy.open( TIDY_OPTIONS ) do |tidy| xml = tidy.clean( source ) errors = tidy.errors self.log.error( errors.join('; ') ) unless errors.empty? return xml end end end # class Strelka::CMS::Page::CleanupFilter
Version data entries
6 entries across 6 versions & 1 rubygems