With the power of bash piping and a tiny python script you can see what css rules could stand to be merged into simple classes.
Last active
December 31, 2015 02:39
-
-
Save cpdean/7922488 to your computer and use it in GitHub Desktop.
put CSS files next to this and find redundant rules. maybe you can use that to guide yourself in an OOCSS refactor
This file contains 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
#/bin/sh | |
cat *css | python properties.py | sort | uniq -c | sort -n |
This file contains 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
# parse out the css properties that are piped in | |
import tinycss | |
import sys | |
parser = tinycss.make_parser("page3") | |
parsed = parser.parse_stylesheet_file(sys.stdin) | |
for r in parsed.rules: | |
for d in r.declarations: | |
try: | |
print d.name + ": " + d.value.as_css() | |
except UnicodeEncodeError as e: | |
pass # fuckit |
This file contains 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
tinycss==0.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment