Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Created July 15, 2011 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdxmph/1084017 to your computer and use it in GitHub Desktop.
Save pdxmph/1084017 to your computer and use it in GitHub Desktop.
Newsletter Stylify Markup
#!/usr/bin/env ruby -wKU
require "rubygems"
require "nokogiri"
attribs = {
"h3" => "font-size: 16px; font-weight: bold; margin: 0 0 10px; padding: 0 14px;",
"p" => "margin: 0 0 8px; padding: 0 12px;",
"li" => "margin-top:8px;",
"ul" => "margin: 0 0 8px 1.5em; padding: 0 12px;"
}
doc = STDIN.read
html = Nokogiri::HTML(doc)
attribs.each do |node,style|
html.css(node).each do |e|
e.set_attribute('style',style)
end
end
puts html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment