• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

_setup/H11-Oct-2015-3,9742,992

bench/H11-Oct-2015-4,7674,300

docs/H11-Oct-2015-549455

tests/H11-Oct-2015-1,6631,373

LICENSEH A D17-Mar-201111.1 KiB202169

MANIFESTH A D11-Oct-201510.8 KiB370369

PKG-INFOH A D11-Oct-201515.9 KiB317261

README.rstH A D11-Oct-20154.3 KiB154104

bench.shH A D11-Oct-2015455 2822

package.cfgH A D11-Oct-20151.6 KiB8366

rcssmin.cH A D11-Oct-201529 KiB1,164849

rcssmin.pyH A D11-Oct-201513.1 KiB375292

run_tests.pyH A D11-Oct-20155 KiB167130

setup.pyH A D08-Feb-20141.2 KiB4315

README.rst

1.. -*- coding: utf-8 -*-
2
3=====================================
4 rCSSmin - A CSS Minifier For Python
5=====================================
6
7TABLE OF CONTENTS
8-----------------
9
101. Introduction
112. Copyright and License
123. System Requirements
134. Installation
145. Documentation
156. Bugs
167. Author Information
17
18
19INTRODUCTION
20------------
21
22RCSSmin is a CSS minifier written in python.
23
24The minifier is based on the semantics of the `YUI compressor`_\, which itself
25is based on `the rule list by Isaac Schlueter`_\.
26
27This module is a re-implementation aiming for speed instead of maximum
28compression, so it can be used at runtime (rather than during a preprocessing
29step). RCSSmin does syntactical compression only (removing spaces, comments
30and possibly semicolons). It does not provide semantic compression (like
31removing empty blocks, collapsing redundant properties etc). It does, however,
32support various CSS hacks (by keeping them working as intended).
33
34Here's a feature list:
35
36- Strings are kept, except that escaped newlines are stripped
37- Space/Comments before the very end or before various characters are
38  stripped: ``:{});=>],!`` (The colon (``:``) is a special case, a single
39  space is kept if it's outside a ruleset.)
40- Space/Comments at the very beginning or after various characters are
41  stripped: ``{}(=:>[,!``
42- Optional space after unicode escapes is kept, resp. replaced by a simple
43  space
44- whitespaces inside ``url()`` definitions are stripped
45- Comments starting with an exclamation mark (``!``) can be kept optionally.
46- All other comments and/or whitespace characters are replaced by a single
47  space.
48- Multiple consecutive semicolons are reduced to one
49- The last semicolon within a ruleset is stripped
50- CSS Hacks supported:
51
52  - IE7 hack (``>/**/``)
53  - Mac-IE5 hack (``/*\*/.../**/``)
54  - The boxmodelhack is supported naturally because it relies on valid CSS2
55    strings
56  - Between ``:first-line`` and the following comma or curly brace a space is
57    inserted. (apparently it's needed for IE6)
58  - Same for ``:first-letter``
59
60rcssmin.c is a reimplementation of rcssmin.py in C and improves runtime up to
61factor 100 or so (depending on the input). docs/BENCHMARKS in the source
62distribution contains the details.
63
64.. _YUI compressor: https://github.com/yui/yuicompressor/
65
66.. _the rule list by Isaac Schlueter: https://github.com/isaacs/cssmin/
67
68
69COPYRIGHT AND LICENSE
70---------------------
71
72Copyright 2011 - 2015
73André Malo or his licensors, as applicable.
74
75The whole package (except for the files in the bench/ directory)
76is distributed under the Apache License Version 2.0. You'll find a copy in the
77root directory of the distribution or online at:
78<http://www.apache.org/licenses/LICENSE-2.0>.
79
80
81SYSTEM REQUIREMENTS
82-------------------
83
84Both python 2 (>=2.4) and python 3 are supported.
85
86
87INSTALLATION
88------------
89
90Using pip
91~~~~~~~~~
92
93$ pip install rcssmin
94
95
96Using distutils
97~~~~~~~~~~~~~~~
98
99$ python setup.py install
100
101The following extra options to the install command may be of interest:
102
103   --without-c-extensions  Don't install C extensions
104   --without-docs          Do not install documentation files
105
106
107Drop-in
108~~~~~~~
109
110rCSSmin effectively consists of two files: rcssmin.py and rcssmin.c, the
111latter being entirely optional. So, for simple integration you can just
112copy rcssmin.py into your project and use it.
113
114
115DOCUMENTATION
116-------------
117
118A generated API documentation is available in the docs/apidoc/ directory.
119But you can just look into the module. It provides a simple function,
120called cssmin which takes the CSS as a string and returns the minified
121CSS as a string.
122
123The module additionally provides a "streamy" interface:
124
125$ python -mrcssmin <css >minified
126
127It takes two options:
128
129  -b  Keep bang-comments (Comments starting with an exclamation mark)
130  -p  Force using the python implementation (not the C implementation)
131
132The latest documentation is also available online at
133<http://opensource.perlig.de/rcssmin/>.
134
135
136BUGS
137----
138
139No bugs, of course. ;-)
140But if you've found one or have an idea how to improve rcssmin, feel free to
141send a pull request on `github <https://github.com/ndparker/rcssmin>`_ or
142send a mail to <rcssmin-bugs@perlig.de>.
143
144
145AUTHOR INFORMATION
146------------------
147
148André "nd" Malo <nd@perlig.de>
149GPG: 0x8103A37E
150
151
152  If God intended people to be naked, they would be born that way.
153                                                   -- Oscar Wilde
154