| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # -*- coding: ascii -*- | 2 # -*- coding: ascii -*- |
| 3 r""" | 3 r""" |
| 4 ===================== | 4 ===================== |
| 5 Javascript Minifier | 5 Javascript Minifier |
| 6 ===================== | 6 ===================== |
| 7 | 7 |
| 8 rJSmin is a javascript minifier written in python. | 8 rJSmin is a javascript minifier written in python. |
| 9 | 9 |
| 10 The minifier is based on the semantics of `jsmin.c by Douglas Crockford`_\\. | 10 The minifier is based on the semantics of `jsmin.c by Douglas Crockford`_\\. |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 return space_sub_banged( | 336 return space_sub_banged( |
| 337 space_subber_banged, '\n%s\n' % script | 337 space_subber_banged, '\n%s\n' % script |
| 338 ).strip() | 338 ).strip() |
| 339 else: | 339 else: |
| 340 return space_sub_simple( | 340 return space_sub_simple( |
| 341 space_subber_simple, '\n%s\n' % script | 341 space_subber_simple, '\n%s\n' % script |
| 342 ).strip() | 342 ).strip() |
| 343 | 343 |
| 344 return jsmin | 344 return jsmin |
| 345 | 345 |
| 346 jsmin = _make_jsmin() | 346 jsmin = _make_jsmin(python_only=True) # pylint: disable = invalid-name |
| 347 | 347 |
| 348 | 348 |
| 349 def jsmin_for_posers(script, keep_bang_comments=False): | 349 def jsmin_for_posers(script, keep_bang_comments=False): |
| 350 r""" | 350 r""" |
| 351 Minify javascript based on `jsmin.c by Douglas Crockford`_\. | 351 Minify javascript based on `jsmin.c by Douglas Crockford`_\. |
| 352 | 352 |
| 353 Instead of parsing the stream char by char, it uses a regular | 353 Instead of parsing the stream char by char, it uses a regular |
| 354 expression approach which minifies the whole script with one big | 354 expression approach which minifies the whole script with one big |
| 355 substitution regex. | 355 substitution regex. |
| 356 | 356 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if '-p' in argv or '-bp' in argv or '-pb' in argv: | 506 if '-p' in argv or '-bp' in argv or '-pb' in argv: |
| 507 xjsmin = _make_jsmin(python_only=True) | 507 xjsmin = _make_jsmin(python_only=True) |
| 508 else: | 508 else: |
| 509 xjsmin = jsmin | 509 xjsmin = jsmin |
| 510 | 510 |
| 511 _sys.stdout.write(xjsmin( | 511 _sys.stdout.write(xjsmin( |
| 512 _sys.stdin.read(), keep_bang_comments=keep_bang_comments | 512 _sys.stdin.read(), keep_bang_comments=keep_bang_comments |
| 513 )) | 513 )) |
| 514 | 514 |
| 515 main() | 515 main() |
| OLD | NEW |