Last active
June 12, 2017 05:03
-
-
Save clockworkpc/c14b75987eb78bddd4c8241e6c67799c to your computer and use it in GitHub Desktop.
Convert HTML Classes to CSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html_file = ARGV[0] | |
css_file = "app/assets/stylesheets/css_output.css" | |
class_array = Array.new | |
open_html_file = File.readlines(html_file) | |
open_css_file = File.open(css_file, "w+") | |
open_html_file.each do |line| | |
search_string = /class="[a-z]*"/ | |
if line.match?(search_string) | |
nugget = line[search_string] | |
class_name = nugget[7..-2] | |
class_array.push(class_name) | |
end | |
end | |
class_array.uniq! | |
class_array.sort! | |
class_array.each do |item| | |
css_conversion = "\n." + item + "{\n\t\n}" | |
open_css_file.write(css_conversion) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment