Skip to content

Instantly share code, notes, and snippets.

@derek-watson
Created September 14, 2012 20:16
Show Gist options
  • Save derek-watson/3724453 to your computer and use it in GitHub Desktop.
Save derek-watson/3724453 to your computer and use it in GitHub Desktop.
Strip all inline style attributes from HTML
# - Reads from STDIN until EOF
# - Writes to STDOUT.
# - Requires Nokogiri (gem install nokogiri)
#
# Hi Tom!
require 'nokogiri'
doc = Nokogiri::HTML.parse(STDIN.read)
doc.css('[style]').each do |node|
node.delete 'style'
end
puts doc.to_s
@tadman
Copy link

tadman commented Sep 14, 2012

require'nokogiri';d=Nokogiri::HTML.parse STDIN.read;d.css('[style]').each{|n|n.delete'style'};puts d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment