Class: Strelka::CMS::PageFilter::Cleanup

Inherits:
Strelka::CMS::PageFilter
  • Object
show all
Defined in:
lib/strelka/cms/pagefilter/cleanup.rb

Overview

A filter that cleans up broken HTML using libtidy.

Constant Summary collapse

TIDY_OPTIONS =

Options to pass to libtidy

{
		: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'
}

Instance Method Summary collapse

Instance Method Details

#process(source, page) ⇒ Object

Process the page‘s source with the filter and return the altered content.



28
29
30
31
32
33
34
35
36
37
# File 'lib/strelka/cms/pagefilter/cleanup.rb', line 28

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