Sha256: 1c63151fdf89ba362e5742bbdc750c0c9bc2e9177fd5511a13cc7c0ce569d970

Contents?: true

Size: 691 Bytes

Versions: 2

Compression:

Stored size: 691 Bytes

Contents

# encoding: utf-8

module ::Nanoc::Extra::Checking::Checks
  class HTML < ::Nanoc::Extra::Checking::Check
    identifier :html

    def run
      require 'w3c_validators'

      Dir[site.config[:output_dir] + '/**/*.{htm,html}'].each do |filename|
        results = ::W3CValidators::MarkupValidator.new.validate_file(filename)
        lines = File.readlines(filename)
        results.errors.each do |e|
          line_num = e.line.to_i - 1
          line = lines[line_num]
          message = e.message.gsub(%r{\s+}, ' ').strip.sub(/\s+:$/, '')
          desc = "line #{line_num + 1}: #{message}: #{line}"
          add_issue(desc, subject: filename)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-3.8.0 lib/nanoc/extra/checking/checks/html.rb
nanoc-3.7.5 lib/nanoc/extra/checking/checks/html.rb