1<?xml version="1.0" encoding="ascii"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 3 "DTD/xhtml1-transitional.dtd"> 4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5<head> 6 <title>rcssmin</title> 7 <link rel="stylesheet" href="epydoc.css" type="text/css" /> 8 <script type="text/javascript" src="epydoc.js"></script> 9</head> 10 11<body bgcolor="white" text="black" link="blue" vlink="#204080" 12 alink="#204080"> 13<!-- ==================== NAVIGATION BAR ==================== --> 14<table class="navbar" border="0" width="100%" cellpadding="0" 15 bgcolor="#a0c0ff" cellspacing="0"> 16 <tr valign="middle"> 17 <!-- Home link --> 18 <th bgcolor="#70b0f0" class="navbar-select" 19 > Home </th> 20 21 <!-- Tree link --> 22 <th> <a 23 href="module-tree.html">Trees</a> </th> 24 25 <!-- Index link --> 26 <th> <a 27 href="identifier-index.html">Indices</a> </th> 28 29 <!-- Help link --> 30 <th> <a 31 href="help.html">Help</a> </th> 32 33 <!-- Project homepage --> 34 <th class="navbar" align="right" width="100%"> 35 <table border="0" cellpadding="0" cellspacing="0"> 36 <tr><th class="navbar" align="center" 37 ><a href="http://opensource.perlig.de/rcssmin/" target="_top">Visit rcssmin Online</a></th> 38 </tr></table></th> 39 </tr> 40</table> 41<table width="100%" cellpadding="0" cellspacing="0"> 42 <tr valign="top"> 43 <td width="100%"> 44 <span class="breadcrumbs"> 45 Module rcssmin 46 </span> 47 </td> 48 <td> 49 <table cellpadding="0" cellspacing="0"> 50 <!-- hide/show private --> 51 </table> 52 </td> 53 </tr> 54</table> 55<!-- ==================== MODULE DESCRIPTION ==================== --> 56<h1 class="epydoc">Module rcssmin</h1><p class="nomargin-top"><span class="codelink"><a href="rcssmin-pysrc.html">source code</a></span></p> 57<p>CSS Minifier.</p> 58<p>The minifier is based on the semantics of the <a class="rst-reference external" href="https://github.com/yui/yuicompressor/" target="_top">YUI compressor</a>, which 59itself is based on <a class="rst-reference external" href="https://github.com/isaacs/cssmin/" target="_top">the rule list by Isaac Schlueter</a>.</p> 60<p>This module is a re-implementation aiming for speed instead of maximum 61compression, so it can be used at runtime (rather than during a preprocessing 62step). RCSSmin does syntactical compression only (removing spaces, comments 63and possibly semicolons). It does not provide semantic compression (like 64removing empty blocks, collapsing redundant properties etc). It does, however, 65support various CSS hacks (by keeping them working as intended).</p> 66<p>Here's a feature list:</p> 67<ul class="rst-simple"> 68<li>Strings are kept, except that escaped newlines are stripped</li> 69<li>Space/Comments before the very end or before various characters are 70stripped: <tt class="rst-docutils literal"><span class="pre">:{});=>+],!</span></tt> (The colon (<tt class="rst-docutils literal">:</tt>) is a special case, a single 71space is kept if it's outside a ruleset.)</li> 72<li>Space/Comments at the very beginning or after various characters are 73stripped: <tt class="rst-docutils literal"><span class="pre">{}(=:>+[,!</span></tt></li> 74<li>Optional space after unicode escapes is kept, resp. replaced by a simple 75space</li> 76<li>whitespaces inside <tt class="rst-docutils literal">url()</tt> definitions are stripped</li> 77<li>Comments starting with an exclamation mark (<tt class="rst-docutils literal">!</tt>) can be kept optionally.</li> 78<li>All other comments and/or whitespace characters are replaced by a single 79space.</li> 80<li>Multiple consecutive semicolons are reduced to one</li> 81<li>The last semicolon within a ruleset is stripped</li> 82<li>CSS Hacks supported:<ul> 83<li>IE7 hack (<tt class="rst-docutils literal"><span class="pre">>/**/</span></tt>)</li> 84<li>Mac-IE5 hack (<tt class="rst-docutils literal"><span class="pre">/*\*/.../**/</span></tt>)</li> 85<li>The boxmodelhack is supported naturally because it relies on valid CSS2 86strings</li> 87<li>Between <tt class="rst-docutils literal"><span class="pre">:first-line</span></tt> and the following comma or curly brace a space is 88inserted. (apparently it's needed for IE6)</li> 89<li>Same for <tt class="rst-docutils literal"><span class="pre">:first-letter</span></tt></li> 90</ul> 91</li> 92</ul> 93<p>rcssmin.c is a reimplementation of rcssmin.py in C and improves runtime up to 94factor 100 or so (depending on the input). docs/BENCHMARKS in the source 95distribution contains the details.</p> 96<p>Both python 2 (>= 2.4) and python 3 are supported.</p> 97 98<hr /> 99<div class="fields"> <p><strong>Copyright:</strong> 100 Copyright 2011 - 2014 101André Malo or his licensors, as applicable 102 </p> 103 <p><strong>License:</strong> 104 <p>Licensed under the Apache License, Version 2.0 (the "License"); 105you may not use this file except in compliance with the License. 106You may obtain a copy of the License at</p> 107<blockquote> 108<a class="rst-reference external" href="http://www.apache.org/licenses/LICENSE-2.0" target="_top">http://www.apache.org/licenses/LICENSE-2.0</a></blockquote> 109<p>Unless required by applicable law or agreed to in writing, software 110distributed under the License is distributed on an "AS IS" BASIS, 111WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 112See the License for the specific language governing permissions and 113limitations under the License.</p> 114 </p> 115 <p><strong>Version:</strong> 116 1.0.5 117 </p> 118 <p><strong>Author:</strong> 119 André Malo 120 </p> 121</div><!-- ==================== FUNCTIONS ==================== --> 122<a name="section-Functions"></a> 123<table class="summary" border="1" cellpadding="3" 124 cellspacing="0" width="100%" bgcolor="white"> 125<tr bgcolor="#70b0f0" class="table-header"> 126 <td align="left" colspan="2" class="table-header"> 127 <span class="table-header">Functions</span></td> 128</tr> 129<tr> 130 <td width="15%" align="right" valign="top" class="summary"> 131 <span class="summary-type"><tt class="rst-docutils literal">str</tt></span> 132 </td><td class="summary"> 133 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 134 <tr> 135 <td><span class="summary-sig"><a href="rcssmin-module.html#cssmin" class="summary-sig-name">cssmin</a>(<span class="summary-sig-arg">style</span>, 136 <span class="summary-sig-arg">keep_bang_comments</span>=<span class="summary-sig-default">False</span>)</span><br /> 137 Minify CSS.</td> 138 <td align="right" valign="top"> 139 <span class="codelink"><a href="rcssmin-pysrc.html#cssmin">source code</a></span> 140 141 </td> 142 </tr> 143 </table> 144 145 </td> 146 </tr> 147</table> 148<!-- ==================== FUNCTION DETAILS ==================== --> 149<a name="section-FunctionDetails"></a> 150<table class="details" border="1" cellpadding="3" 151 cellspacing="0" width="100%" bgcolor="white"> 152<tr bgcolor="#70b0f0" class="table-header"> 153 <td align="left" colspan="2" class="table-header"> 154 <span class="table-header">Function Details</span></td> 155</tr> 156</table> 157<a name="cssmin"></a> 158<div> 159<table class="details" border="1" cellpadding="3" 160 cellspacing="0" width="100%" bgcolor="white"> 161<tr><td> 162 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 163 <tr valign="top"><td> 164 <h3 class="epydoc"><span class="sig"><span class="sig-name">cssmin</span>(<span class="sig-arg">style</span>, 165 <span class="sig-arg">keep_bang_comments</span>=<span class="sig-default">False</span>)</span> 166 </h3> 167 </td><td align="right" valign="top" 168 ><span class="codelink"><a href="rcssmin-pysrc.html#cssmin">source code</a></span> 169 </td> 170 </tr></table> 171 172 Minify CSS. 173 <dl class="fields"> 174 <dt>Parameters:</dt> 175 <dd><ul class="nomargin-top"> 176 <li><strong class="pname"><code>style</code></strong> (<tt class="rst-docutils literal">str</tt>) - CSS to minify</li> 177 <li><strong class="pname"><code>keep_bang_comments</code></strong> (<tt class="rst-docutils literal">bool</tt>) - Keep comments starting with an exclamation mark? (<tt class="rst-docutils literal"><span class="pre">/*!...*/</span></tt>)</li> 178 </ul></dd> 179 <dt>Returns: <tt class="rst-docutils literal">str</tt></dt> 180 <dd>Minified style</dd> 181 </dl> 182</td></tr></table> 183</div> 184<br /> 185<!-- ==================== NAVIGATION BAR ==================== --> 186<table class="navbar" border="0" width="100%" cellpadding="0" 187 bgcolor="#a0c0ff" cellspacing="0"> 188 <tr valign="middle"> 189 <!-- Home link --> 190 <th bgcolor="#70b0f0" class="navbar-select" 191 > Home </th> 192 193 <!-- Tree link --> 194 <th> <a 195 href="module-tree.html">Trees</a> </th> 196 197 <!-- Index link --> 198 <th> <a 199 href="identifier-index.html">Indices</a> </th> 200 201 <!-- Help link --> 202 <th> <a 203 href="help.html">Help</a> </th> 204 205 <!-- Project homepage --> 206 <th class="navbar" align="right" width="100%"> 207 <table border="0" cellpadding="0" cellspacing="0"> 208 <tr><th class="navbar" align="center" 209 ><a href="http://opensource.perlig.de/rcssmin/" target="_top">Visit rcssmin Online</a></th> 210 </tr></table></th> 211 </tr> 212</table> 213 214<script type="text/javascript"> 215 <!-- 216 // Private objects are initially displayed (because if 217 // javascript is turned off then we want them to be 218 // visible); but by default, we want to hide them. So hide 219 // them unless we have a cookie that says to show them. 220 checkCookie(); 221 // --> 222</script> 223</body> 224</html> 225