File: README.html

package info (click to toggle)
cssutils 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,312 kB
  • sloc: python: 23,625; javascript: 803; sh: 62; makefile: 8
file content (266 lines) | stat: -rw-r--r-- 17,807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>README &mdash; cssutils 0.9.8 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '0.9.8',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="cssutils 0.9.8 documentation" href="index.html" />
    <link rel="next" title="CHANGELOG" href="CHANGELOG.html" />
    <link rel="prev" title="cssutils" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="CHANGELOG.html" title="CHANGELOG"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="cssutils"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">cssutils 0.9.8 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="readme">
<h1>README<a class="headerlink" href="#readme" title="Permalink to this headline">¶</a></h1>
<div class="section" id="cssutils-css-cascading-style-sheets-library-for-python">
<h2>cssutils: CSS Cascading Style Sheets library for Python<a class="headerlink" href="#cssutils-css-cascading-style-sheets-library-for-python" title="Permalink to this headline">¶</a></h2>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Copyright:</th><td class="field-body">2004-2011 Christof Hoeke</td>
</tr>
</tbody>
</table>
<div class="section" id="overview">
<h3>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h3>
<p>A Python package to parse and build CSS Cascading Style Sheets. DOM only, not any rendering facilities!</p>
<p>Based upon and partly implementing the following specifications :</p>
<dl class="docutils">
<dt><a class="reference external" href="http://www.w3.org/TR/CSS2/">CSS 2.1rev1</a></dt>
<dd>General CSS rules and properties are defined here</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/css3-syntax/">CSS3 Module: Syntax</a></dt>
<dd>Used in parts since cssutils 0.9.4. cssutils tries to use the features from CSS 2.1 and CSS 3 with preference to CSS3 but as this is not final yet some parts are from CSS 2.1</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/css3-fonts/">CSS Fonts Module Level 3</a></dt>
<dd>Added changes and additional stuff (since cssutils v0.9.6)</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/css3-mediaqueries/">MediaQueries</a></dt>
<dd>MediaQueries are part of <tt class="docutils literal"><span class="pre">stylesheets.MediaList</span></tt> since v0.9.4, used in &#64;import and &#64;media rules.</dd>
<dt><a class="reference external" href="http://dev.w3.org/csswg/css3-namespace/">Namespaces</a></dt>
<dd>Added in v0.9.1, updated to definition in CSSOM in v0.9.4, updated in 0.9.5 for dev version</dd>
<dt><a class="reference external" href="`http://www.w3.org/TR/css3-page/">CSS3 Module: Pages Media</a></dt>
<dd>Most properties of this spec are implemented and the additional &#64;rules should at least parse (as <tt class="docutils literal"><span class="pre">CSSUnknownRule</span></tt>)</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/css3-selectors/">Selectors</a></dt>
<dd>The selector syntax defined here (and not in CSS 2.1) should be parsable with cssutils (<em>should</em> mind though ;) )</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/css3-background/">CSS Backgrounds and Borders Module Level 3</a>, <a class="reference external" href="http://www.w3.org/TR/css3-ui/#resize">CSS3 Basic User Interface Module</a>, <a class="reference external" href="http://www.w3.org/TR/css3-text/">CSS Text Level 3</a></dt>
<dd>Some validation for properties included, mainly  <cite>cursor</cite>, <cite>outline</cite>, <cite>resize</cite>, <cite>box-shadow</cite>, <cite>text-shadow</cite></dd>
<dt><a class="reference external" href="http://disruptive-innovations.com/zoo/cssvariables/">Variables</a></dt>
<dd>Experimental specification of CSS Variables which cssutils implements partly. Media specific variables are not supported.</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html">DOM Level 2 Style CSS</a></dt>
<dd>DOM for package css. 0.9.8 removes support for CSSValue and related API, see PropertyValue and Value API for now</dd>
<dt><a class="reference external" href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html">DOM Level 2 Style Stylesheets</a></dt>
<dd>DOM for package stylesheets</dd>
<dt><a class="reference external" href="http://dev.w3.org/csswg/cssom/">CSSOM</a></dt>
<dd>A few details (mainly the NamespaceRule DOM) are taken from here. Plan is to move implementation to the stuff defined here which is newer but still no REC so might change anytime...</dd>
</dl>
<p>The cssutils tokenizer is a customized implementation of <a class="reference external" href="http://www.w3.org/TR/css3-syntax/">CSS3 Module: Syntax (W3C Working Draft 13 August 2003)</a> which itself is based on the CSS 2.1 tokenizer. It tries to be as compliant as possible but uses some (helpful) parts of the CSS 2.1 tokenizer.</p>
<p>I guess cssutils is neither CSS 2.1 nor CSS 3 compliant but tries to at least be able to parse both grammars including some more real world cases (some CSS hacks are actually parsed and serialized). Both official grammars are not final nor bugfree but still feasible. cssutils aim is not to be fully compliant to any CSS specification (the specifications seem to be in a constant flow anyway) but cssutils <em>should</em> be able to read and write as many as possible CSS stylesheets &#8220;in the wild&#8221; while at the same time implement the official APIs which are well documented. Some minor extensions are provided as well.</p>
<p>Please visit <a class="reference external" href="http://cthedot.de/cssutils/">http://cthedot.de/cssutils/</a> or <a class="reference external" href="http://code.google.com/p/cssutils/">http://code.google.com/p/cssutils/</a> for more details.</p>
<p>There is also a low-traffic <a class="reference external" href="http://groups.google.com/group/cssutils">cssutils discussion group</a>.</p>
</div>
<div class="section" id="compatibility">
<h3>Compatibility<a class="headerlink" href="#compatibility" title="Permalink to this headline">¶</a></h3>
<p>cssutils is developed on standard Python but works under Python 2.x (from 2.5, v2.5.4 tested), 3.x (v3.2.2 tested) and Jython (from 2.5.1). IronPython has not been tested yet but might work? Python 2.4 and older are not supported since cssutils 0.9.8 anymore.</p>
</div>
<div class="section" id="license">
<h3>License<a class="headerlink" href="#license" title="Permalink to this headline">¶</a></h3>
<p>Copyright 2005 - 2011 Christof Hoeke</p>
<p>cssutils is published under the LGPL 3 or later</p>
<p>cssutils is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
<p>cssutils is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</p>
<p>You should have received a copy of the GNU Lesser General Public License along with cssutils. If not, see <a class="reference external" href="http://www.gnu.org/licenses">http://www.gnu.org/licenses</a>.</p>
</div>
<div class="section" id="installation">
<h3>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h3>
<p>From 0.9.6 cssutils uses <a class="reference external" href="http://pypi.python.org/pypi/distribute">Distribute</a></p>
<p>After installing Distribute use:</p>
<div class="highlight-python"><pre>&gt; easy_install cssutils</pre>
</div>
<p>to install the latest version of cssutils.</p>
<p>Alternatively download the provided source distribution. Expand the file and from a command line install with:</p>
<div class="highlight-python"><pre>&gt; python setup.py install</pre>
</div>
<p>To uninstall remove any registrations of cssutils eggs with Distribute and remove the eggs which should be installed at PYTHONDIR/Lib/site-packages/cssutils too.</p>
</div>
<div class="section" id="example">
<h3>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># -*- coding: utf-8 -*-</span>
<span class="kn">import</span> <span class="nn">cssutils</span>

<span class="n">css</span> <span class="o">=</span> <span class="s">u&#39;&#39;&#39;/* a comment with umlaut &amp;auml; */</span>
<span class="s">     @namespace html &quot;http://www.w3.org/1999/xhtml&quot;;</span>
<span class="s">     @variables { BG: #fff }</span>
<span class="s">     html|a { color:red; background: var(BG) }&#39;&#39;&#39;</span>
<span class="n">sheet</span> <span class="o">=</span> <span class="n">cssutils</span><span class="o">.</span><span class="n">parseString</span><span class="p">(</span><span class="n">css</span><span class="p">)</span>

<span class="k">for</span> <span class="n">rule</span> <span class="ow">in</span> <span class="n">sheet</span><span class="p">:</span>
    <span class="k">if</span> <span class="n">rule</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="n">rule</span><span class="o">.</span><span class="n">STYLE_RULE</span><span class="p">:</span>
        <span class="c"># find property</span>
        <span class="k">for</span> <span class="nb">property</span> <span class="ow">in</span> <span class="n">rule</span><span class="o">.</span><span class="n">style</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">property</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s">&#39;color&#39;</span><span class="p">:</span>
                <span class="nb">property</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="s">&#39;green&#39;</span>
                <span class="nb">property</span><span class="o">.</span><span class="n">priority</span> <span class="o">=</span> <span class="s">&#39;IMPORTANT&#39;</span>
                <span class="k">break</span>
        <span class="c"># or simply:</span>
        <span class="n">rule</span><span class="o">.</span><span class="n">style</span><span class="p">[</span><span class="s">&#39;margin&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;01.0eM&#39;</span> <span class="c"># or: (&#39;1em&#39;, &#39;important&#39;)</span>

<span class="n">sheet</span><span class="o">.</span><span class="n">encoding</span> <span class="o">=</span> <span class="s">&#39;ascii&#39;</span>
<span class="n">sheet</span><span class="o">.</span><span class="n">namespaces</span><span class="p">[</span><span class="s">&#39;xhtml&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;http://www.w3.org/1999/xhtml&#39;</span>
<span class="n">sheet</span><span class="o">.</span><span class="n">namespaces</span><span class="p">[</span><span class="s">&#39;atom&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;http://www.w3.org/2005/Atom&#39;</span>
<span class="n">sheet</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;atom|title {color: #000000 !important}&#39;</span><span class="p">)</span>
<span class="n">sheet</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s">&#39;@import &quot;sheets/import.css&quot;;&#39;</span><span class="p">)</span>

<span class="c"># cssutils.ser.prefs.resolveVariables == True since 0.9.7b2</span>
<span class="k">print</span> <span class="n">sheet</span><span class="o">.</span><span class="n">cssText</span>
</pre></div>
</div>
<p>results in:</p>
<div class="highlight-python"><pre>@charset "ascii";
@import "sheets/import.css";
/* a comment with umlaut \E4  */
@namespace xhtml "http://www.w3.org/1999/xhtml";
@namespace atom "http://www.w3.org/2005/Atom";
xhtml|a {
    color: green !important;
    background: #fff;
    margin: 1em
    }
atom|title {
    color: #000 !important
    }</pre>
</div>
</div>
<div class="section" id="documentation">
<h3>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h3>
<p>The current documenation can be found at <a class="reference external" href="http://packages.python.org/cssutils/">http://packages.python.org/cssutils/</a></p>
</div>
<div class="section" id="kind-request">
<h3>Kind Request<a class="headerlink" href="#kind-request" title="Permalink to this headline">¶</a></h3>
<p>cssutils is far from being perfect or even complete. If you find any bugs (especially specification violations) or have problems or suggestions please put them in the <a class="reference external" href="https://bitbucket.org/cthedot/cssutils/issues">Issue Tracker</a> at Bitbucket.</p>
</div>
<div class="section" id="thanks">
<h3>Thanks<a class="headerlink" href="#thanks" title="Permalink to this headline">¶</a></h3>
<p>Thanks to Jason R. Coombs, Simon Sapin and Walter Doerwald for patches, help and discussion. Thanks to Kevin D. Smith for the value validating module. Thanks also to Cory Dodt, Tim Gerla, James Dobson and Amit Moscovich for helpful suggestions and code patches. Thanks to Fredrik Hedman for help on port of encutils to Python 3.</p>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">README</a><ul>
<li><a class="reference internal" href="#cssutils-css-cascading-style-sheets-library-for-python">cssutils: CSS Cascading Style Sheets library for Python</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#compatibility">Compatibility</a></li>
<li><a class="reference internal" href="#license">License</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#documentation">Documentation</a></li>
<li><a class="reference internal" href="#kind-request">Kind Request</a></li>
<li><a class="reference internal" href="#thanks">Thanks</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="index.html"
                        title="previous chapter">cssutils</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="CHANGELOG.html"
                        title="next chapter">CHANGELOG</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/README.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="CHANGELOG.html" title="CHANGELOG"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="cssutils"
             >previous</a> |</li>
        <li><a href="index.html">cssutils 0.9.8 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2004-2011, Christof Höke.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>