source code of /small-scripts/css-minify

Last modified
Lines 24

Parent directory Download CGIread sitemap Main page

Quick links: (none)

  1. #!/usr/bin/python
  2. import sys
  3. import re
  4. patterns = [
  5.     ('; *', ';'),
  6.     (': *', ':'),
  7.     (' *{ *', '{'),
  8.     (' *} *', '}'),
  9.     (', *', ','),
  10. ]
  11. s = sys.stdin.read().replace('\n', '')
  12. s = ''.join(map(lambda x: re.sub('/\\*.*$', '', x), s.split('*/')))
  13. for pair in patterns:
  14.     s = re.sub(pair[0], pair[1], s)
  15. if len(sys.argv) == 2:
  16.     sys.stdout.write('/*\n{}\n*/'.format(sys.argv[1]))
  17. sys.stdout.write(s)
  18. sys.stdout.write('\n')