Skip to content

Instantly share code, notes, and snippets.

@neall
Created June 8, 2009 13:01
Show Gist options
  • Save neall/125804 to your computer and use it in GitHub Desktop.
Save neall/125804 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML.parse(open('input.html'), nil, 'utf-8')
meta_content_type = Nokogiri::XML::Node.new 'meta', doc
meta_content_type['http-equiv'] = 'Content-Type'
meta_content_type['content'] = 'text/html; charset=utf-8'
doc.search('head').first << meta_content_type
puts doc.to_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment