Skip to content

Instantly share code, notes, and snippets.

@destroytoday
Created August 18, 2011 16:35
Show Gist options
  • Save destroytoday/1154475 to your computer and use it in GitHub Desktop.
Save destroytoday/1154475 to your computer and use it in GitHub Desktop.
Tidies all html files in the site dir
require 'rubygems'
require 'tidy_ffi'
desc "Tidies HTML files"
task :tidy do
Dir.glob('site/**/*.html') do |path|
content = File.open(path).read
File.open(path, 'w') {|file|
file.write TidyFFI::Tidy.new(content, :numeric_entities => 1, :output_html => 1, :merge_divs => 0, :merge_spans => 0, :join_styles => 0, :clean => 1, :indent => 1, :wrap => 0, :drop_empty_paras => 0, :literal_attributes => 1).clean
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment