class Overcommit::Hook::PreCommit::HtmlTidy

Runs ‘tidy` against any modified HTML files.

@see www.html-tidy.org/

Constants

MESSAGE_REGEX

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/html_tidy.rb, line 15
def run
  # example message:
  #   line 4 column 24 - Warning: <html> proprietary attribute "class"
  applicable_files.collect do |file|
    result = execute(command + [file])
    output = result.stderr.chomp

    extract_messages(
      output.split("\n").collect { |msg| "#{file}: #{msg}" },
      MESSAGE_REGEX,
      lambda { |type| type.downcase.to_sym }
    )
  end.flatten
end