Sha256: f96f699b3741aa5a81101d34dfa5425d567c828daa842a4f4d96dba97cc8f9c6

Contents?: true

Size: 927 Bytes

Versions: 18

Compression:

Stored size: 927 Bytes

Contents

# -*- encoding: utf-8 -*-

require 'webgen/content_processor'
require 'webgen/utils/external_command'

module Webgen
  class ContentProcessor

    # Uses the external +tidy+ program to format the content as valid (X)HTML.
    module Tidy

      # Process the content of +context+ with the +tidy+ program.
      def self.call(context)
        Webgen::Utils::ExternalCommand.ensure_available!('tidy', '-v')

        cmd = "tidy -q #{context.website.config['content_processor.tidy.options']}"
        status, stdout, stderr = systemu(cmd, 'stdin' => context.content)
        if status.exitstatus != 0
          stderr.split(/\n/).each do |line|
            context.website.logger.send(status.exitstatus == 1 ? :warn : :error) do
              "Tidy reported problems for <#{context.dest_node.alcn}>: #{line}"
            end
          end
        end
        context.content = stdout
        context
      end

    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/content_processor/tidy.rb
webgen-1.7.2 lib/webgen/content_processor/tidy.rb
webgen-1.7.1 lib/webgen/content_processor/tidy.rb
webgen-1.7.0 lib/webgen/content_processor/tidy.rb
webgen-1.6.0 lib/webgen/content_processor/tidy.rb
webgen-1.5.2 lib/webgen/content_processor/tidy.rb
webgen-1.5.1 lib/webgen/content_processor/tidy.rb
webgen-1.5.0 lib/webgen/content_processor/tidy.rb
webgen-1.4.1 lib/webgen/content_processor/tidy.rb
webgen-1.4.0 lib/webgen/content_processor/tidy.rb
webgen-1.3.0 lib/webgen/content_processor/tidy.rb
webgen-1.2.1 lib/webgen/content_processor/tidy.rb
webgen-1.2.0 lib/webgen/content_processor/tidy.rb
webgen-1.1.0 lib/webgen/content_processor/tidy.rb
webgen-1.0.0 lib/webgen/content_processor/tidy.rb
webgen-1.0.0.beta3 lib/webgen/content_processor/tidy.rb
webgen-1.0.0.beta2 lib/webgen/content_processor/tidy.rb
webgen-1.0.0.beta1 lib/webgen/content_processor/tidy.rb