source code of /small-scripts/css-minify
| Last modified | |
| Lines | 24 |
Parent directory Download CGIread sitemap Main page
Quick links: (none)
#!/usr/bin/python
import sys
import re
patterns = [
('; *', ';'),(': *', ':'),(' *{ *', '{'),(' *} *', '}'),(', *', ','),]
s = sys.stdin.read().replace('\n', '')s = ''.join(map(lambda x: re.sub('/\\*.*$', '', x), s.split('*/')))for pair in patterns:
s = re.sub(pair[0], pair[1], s)
if len(sys.argv) == 2:
sys.stdout.write('/*\n{}\n*/'.format(sys.argv[1]))sys.stdout.write(s)
sys.stdout.write('\n')