Skip to content

Instantly share code, notes, and snippets.

@fareesh
Created February 2, 2016 12:16
Show Gist options
  • Save fareesh/a7bbff23b60482ba7bce to your computer and use it in GitHub Desktop.
Save fareesh/a7bbff23b60482ba7bce to your computer and use it in GitHub Desktop.
# replace.rb
#
# Usage: ruby replace.rb test.html
# Output: test.html with padding CSS replacements
filename = ARGV[0]
pairs = [["padding-top:9px;","padding-top:0px;"],["padding-top: 9px;","padding-top: 0px;"],["padding-bottom: 9px;","padding-bottom: 0px;"],["padding: 9px;","padding-top: 0px; padding-left: 9px; padding-right: 9px; padding-bottom: 0px;"],["padding-bottom:9px;","padding-bottom:0px;"],["padding:9px", "padding-top:0px;padding-bottom:0px;padding-left:9px;padding-right:9px;"]]
str = ""
File.open(filename,"r"){|f|str = f.read}
pairs.each do |pair|
str = str.gsub(pair[0],pair[1])
end
File.open(filename,"w"){|f|f.write(str)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment