Parent

Methods

Included Modules

Class Index [+]

Quicksearch

Webgen::ContentProcessor::Tidy

Uses the external tidy program to format the content as valid (X)HTML.

Public Instance Methods

call(context) click to toggle source

Process the content of context with the tidy program.

    # File lib/webgen/contentprocessor/tidy.rb, line 12
12:     def call(context)
13:       error_file = Tempfile.new('webgen-tidy')
14:       error_file.close
15: 
16:       `tidy -v 2>&1`
17:       if $?.exitstatus != 0
18:         raise Webgen::CommandNotFoundError.new('tidy', self.class.name, context.dest_node)
19:       end
20: 
21:       cmd = "tidy -q -f #{error_file.path} #{context.website.config['contentprocessor.tidy.options']}"
22:       result = IO.popen(cmd, 'r+') do |io|
23:         io.write(context.content)
24:         io.close_write
25:         io.read
26:       end
27:       if $?.exitstatus != 0
28:         File.readlines(error_file.path).each do |line|
29:           log($?.exitstatus == 1 ? :warn : :error) { "Tidy reported problems for <#{context.dest_node}>: #{line}" }
30:         end
31:       end
32:       context.content = result
33:       context
34:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.