module Webgen::ContentProcessor::Tidy
Uses the external tidy
program to format the content as valid (X)HTML.
Public Class Methods
call(context)
click to toggle source
Process the content of context
with the tidy
program.
# File lib/webgen/content_processor/tidy.rb 12 def self.call(context) 13 Webgen::Utils::ExternalCommand.ensure_available!('tidy', '-v') 14 15 cmd = "tidy -q #{context.website.config['content_processor.tidy.options']}" 16 status, stdout, stderr = systemu(cmd, 'stdin' => context.content) 17 if status.exitstatus != 0 18 stderr.split(/\n/).each do |line| 19 context.website.logger.send(status.exitstatus == 1 ? :warn : :error) do 20 "Tidy reported problems for <#{context.dest_node.alcn}>: #{line}" 21 end 22 end 23 end 24 context.content = stdout 25 context 26 end