========================================================
cssutils - CSS Cascading Style Sheets library for Python
========================================================
Copyright (C) 2004-2006 Christof Hoeke
Published under the LGPL, see http://cthedot.de/cssutils/license.html

A Python package to parse and build CSS Cascading Style Sheets. Partly implements the DOM Level 2 Stylesheets  and DOM Level 2 CSS interfaces.

Please visit http://cthedot.de/cssutils/ for full details and updates.


installation
============
From 0.9 cssutils uses EasyInstall. Please find installation instructions and more information about EasyInstall from http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions.

After installing EasyInstall simple use::

    > easy_install cssutils
    
to install the latest version of cssutils.

Alternatively download the provided source distribution. Expand the file and from a command line install with::
    
    > python setup.py install

Before using EasyInstall the first time or using the sdist please remove any old version which should be installed at PYTHONDIR/Lib/site-packages/cssutils.


known issues
============
- @charset not implemented according to spec (plan: 0.91)
- CSS escape sequences are tokenized wrong and do not work properly
- Unexpected end of style sheet not handled according to spec

- CSSStyleDeclaration.getCSSValue and Value Classes are not implemented. These may be implemented in one of the next releases (0.91 or following)

- Properties are not bound to any CSS Version, so all properties are handled so 
  *NOT* as described in http://www.w3.org/TR/CSS21/syndata.html#parsing-errors "Illegal values". (A future version might be customizable to a specific CSS version like 1.0 or 2.1)
- Property.value is only checked for valid CSS2 properties, so will accept more than allowed. In case of an error a WARNING is issued only

- @page rules is disabled (Unknown Rule will be used currently)
- CSSCapture is currently disabled


changes
=======
0.9a6
    - NEW ``Serializer.prefs.keepcomments`` removes all comments if ``False``, defaults to ``True``

    - NEW ``Serializer.prefs.srcatkeywords`` uses literal form of @keyword in source CSS if ``True`` (e.g. ``@im\port``), defaults to ``True`` (``@import``)

    - fixed tokenizer to handle at least simple escapes like ``c\olor`` which is the same as ``color``. The original value is preserved but not used yet except in CSSComments which preserve the original values. See also Serializer.prefs.srcatkeywords

    - ``CSSMediaRule`` tested and lots of bugfixes
        * constructor has **no** parameters anymore (``mediaText`` is removed!)
        * ``addRule`` is DEPRECATED, use ``insertRule(rule)`` with no index instead.
          Synchronized with ``CSSStyleSheet.insertRule``
          
    - setting of ``CSSImportRule.media`` removed, use methods of this object directly.
      Synchronized with ``CSSMediaRule.media``
        
    - ``CSSStyleSheet.insertRule`` raises ``xml.dom.IndexSizeErr`` if an invalid index is given. Index may be ``None`` in which case the rule will be appended.
        Synchronized with ``CSSMediaRule.insertRule``
      
    - CSSStyleDeclaration bugfixes in parsing invalid tokens
    - stylesheets.MediaList bugfixes in parsing uppercase media values like ``PRINT``
    - added more unittests (CSSMediaRule)
    - various bugfixes


0.9a5 061015
    - reimplemented property validator:
        - for unknown CSS2 Properties a INFO message is logged
        - for invalid CSS2 Property values a WARNING message is issued

    - atrules have a new property ``atkeyword`` which is the keyword used in the CSS provided. Normally something like "@import" but may also be an escaped version like "@im\port" or a custom one used in CSSUnknownRule.
    
    - tokenizer and css.selector.Selector 
        - added CSS3 combinator ``~``
        - added CSS3 attribute selectors ``^=``, ``$=``, ``*=`` 
        - added CSS3 pseudo selector ``::`` and pseudo-functions like ``:lang(fr)``
        
    - Token
        - added some new constants mainly replacing DELIM, e.g. UNIVERSAL, GREATER, PLUS, TILDE
        
        (CSS3 see http://www.w3.org/TR/css3-selectors)
        
    - Improved parsing of "Unexpected end of string" according to spec
    - fixed serializing of CSSUnknownRule if ``valid == False``
    
    - Properties may also be set with a numeric value now, before everything had to be a string. Direct use of _Property is discouraged though as it may well be changed again in a future version.

0.9a4 060927
    - CSSStyleSheet: 
        - removed init parameter ``type`` which is now set as a static type to "text/css"
        - removed ``addRule`` which emits DeprecationWarning now
          Use ``insertRule`` without parameter ``index`` 
        - added new methods ``setSerializer(cssserializer)`` and 
          ``setSerializerPref(self, pref, value)`` to control output
          of a stylesheet directly.
          
    - CSSStyleRule:
        - new property ``selectorList`` is an instance of SelectorList
          which contains a list of all Selector elements of the rule
        - removed ``addSelector()`` and ``getSelectors()``,
          use property ``selectorList`` instead
        - removed ``getStyleDeclaration()`` and ``setStyleDeclaration()``, 
          use property ``style`` instead

    - CSSStyleDeclaration:
        - new constructor parameter ``cssText``
    
    - moved ``SelectorList``, ``Selector`` and ``Property`` to own modules.
      Should not be used directly yet anyway.
      
    - Token: renamed ``IMPORTANT`` to ``IMPORTANT_SYM``
        
    - unittests:
        - added tests for CSSStyleSheet, CSSStyleRule, SelectorList, Selector
          CSSStyleDeclaration, _Property

0.9a3 - 060909
    - refined EasyInstall (still some issues to be done)
    - CSSCharsetRule serialized and parsed according to spec only as ``@charset "ENCODING";`` so no comments allowed, only one space before encoding string which MUST use ``"`` as delimiter (see http://www.w3.org/TR/CSS21/syndata.html#q23)
        NOT COMPLETE YET, E.G. BOM HANDLING
        
    - added tests for setting empty cssText for all @rules and CSSStyleRule
    - bugfixes
        - CSSStyleDeclaration: Of two Properties if written directly after another``a:1;b:2`` one was swallowed
    - CSSSerializer: 
        added new class cssutils.serialize.Preferences to control output or CSSSerializer

0.9a2 - 060908
    - using setuptools for deployment
        - new script ``cssparse`` which pprints css "filename"
    
    - subpackages ``css`` and ``stylesheets`` are directly available from ``cssutils`` now
    - renamed module ``cssutils.cssparser`` to ``cssutils.parse`` which should not be used directly anyway. Always use ``cssutils.CSSParser`` or ``cssutils.parse`` (s.b)
    - added utility functions ``parse(cssText)`` and ``parse(filename, encoding='utf-8')`` to cssutils main package which work like the CSSParser functions with the same name and API
    - return value of ``.cssText`` is ``u''`` and not ``None`` if empty now

    - serializing
        - cssutils.Serializer renamed to cssutils.CSSSerializer to improve usage of
           ``from cssutils import *``
        - cssutils has a property "ser" which is used by all classes to serialize themselves
        it is definable with a custom instance of cssutils.Serializer by setting
            cssutils.setCSSSerializer(newserializer)
            
        - prefs['CSSImportrule.href format'] may be set to 
            - 'uri': renders url(...) (default)
            - 'string': renders "..."
            - None: renders as set in CSSImportRule.hreftype
            
    - css.CSSCharsetRule: 
        - improved parsing
        - fixed API handling (setting of encoding did not work)
        
    - css.CSSImportRule:
        - improved parsing
        
    - usage of *.getFormatted emits DeprecationWarning now and returns *.cssText
    
    - lots of bugfixes and refactoring of modules, classes
    - extension and refactoring of unittests
    
0.9a1 - 060905
    - new tokenizer, complete rewrite
        * parses strings and comments
        * parses unicode escape sequences (see following)
        * emits CSS tokens according to spec (update: not all yet (ESCAPE)!)
        
    - renamed module "comment" to "csscomment" and class "Comment" to "CSSComment"
    - configurable Serializer instead of pprint
    - reimplemented CSSMediaRule

----

0.8a6 - 050827
    - bugfixes in valuevalidator regarding values of "background-position", thanks to Tim Gerla!

0.8a5 - 050824
    - bugfix in css.Comment: if constructor was called with empty or no cssText an exception was raised, reported by Tim Gerla!
    - prepared inline comments run through epydoc and generated API docs

0.8a4 - 050814
    - csscapture.py
        * does download linked, inline and @imported stylesheets now
        * renamed csscapture.Capture to csscapture.CSSCapture
        * added options, use ``csspapture.py -h`` to view all options
    - cssutils.css.CSSStyleSheet defines ``literalCssText`` property if property
      ``cssText`` is set. This is the unparsed cssText and might be different to cssText
      e.g. in case of parser errors.

0.8a3 - 050813
    - custom log for CSSparser should work again
    - calling script cssparser has 2 new options (not using optparse yet...)
        cssparser.py filename.css [encoding[, "debug"]]
        1. encoding of the filename.css to parse
        2. if called with "debug" debugging mode is enabled and default log prints all messages
        
    - cssutils.css.CSSUnknownRule reintegrated and Tests added
    - cssutils.Comment reintegrated
        implements css.CSSRule, there a new typevalue COMMENT (=-1) is added
    - lexer does handle strings *almost* right now...
    - bugfixes
    - simplified lexer, still lots of simplification todo
    
0.8a2 - 050731
    - CSSParser may now directly be used from cssutils
      cssutils.cssparser as a standalone script does work too.
    - css.CSSStyleDeclaration.getPropertyCSSValue(name) implemented
    - css.CSSValue updated
    - xml.dom.InvalidModificationErr now raised by CSSRule subclasses instead of xml.dom.SyntaxErr in case a non expected rule has been tried to set
    - test are updated to the new API and work (not complete and exhaustive though but a bit more than for 0.61)
    - bugfixes in some classes due to reanimated tests
    - moved module valuevalidator from cssutils.css to cssutils. 
      Should not be used directly anyway
    - split CSSParser in actual CSSParser and utility module used by CSSParser and each css class cssText setting method
    - loghandler.ErrorHandler does raiseExceptions by default now. Only CSSParser does overwrite this behaviour. Some tests still need to be looked into...


0.8a1 - 050730
    bugfix medialist
        medium "projection" was spelled wrong (ended with a space)

    docs
        new examples and new structure on the website

    NEW API **INCOMPATIBLE API CHANGES**    
        * new package cssutils.css which contains CSS interface implementations (css.CSSStyleSheet, css.CSSRuleList etc)
        * new package cssutils.stylesheets which contains Stylesheets interface implementations are in (stylesheets.StyleSheet, stylesheets.MediaList etc)
        * module cssutils.cssbuilder has therefor been removed and is replaced by packages cssutils.css and cssutils.stylesheets.
          (You may like to define your own cssbuilder module which imports all new classes with their old name if you do not want to change all your code at this time. Usage of the new names is recommended however and there are more subtle changes.)
        * CSS interfaces use W3 DOM names normally starting with CSS... now (e.g. CSSStyleSheet)
        * CSSStyleSheet now uses superclass stylesheets.StyleSheet
        * CSSImportRule is changed to comply to its specification (MediaList is after the URI and not before)
        * CSSFontfaceRule (cssutils FontfaceRule) is removed as CSS 2.1 removed this @ rule completely
        * CSSProperties is removed. Properties are useful in CSSStyleDeclaration only anyway and are used through that class now.
        * some parameters have been renamed to their respective DOM names (e.g. selector is selectorText now in CSSStyleRule constructor
        * the API has been cleaned up a bit. Some redundant methods have been removed.
            - cssmediarule: removed  getRules(), use cssRules property instead
    
        * Comment as a rule is removed currently, might be reintegrated in a future version.
        * some classes which have not been implemented fully anyway are not available until they are finished. This is mainly CSSMediaRule (will follow shortly), CSSUnknownRule, CSSValue and other value classes.

----

0.61 - 050604
    bugfix reported and fixed thanks to Matt Harrison:
        'border-left-width' property was missing from cssvalues.py
    
0.60b
    tiny internal changes

0.60a
    added modules to validate Properties and Values
    thanks to Kevin D. Smith
    
    MediaList renamed media type "speech" to "aural"

0.55_52 - 040517 bugfix bugfix release
    should do test first ;)
    added unittest and fix for fix
    
0.55_51 - 040517 bugfix release
    cssstylesheet.StyleSheet _pprint was renamed to _getCssText but
    the call in pprint was not changed...

0.55_5 - 040509
    API CHANGES
    
    StyleDeclaration 
        addProperty made/named private 
        DEPRECATED anyway, use setProperty
        
        parentRule raises NotImplementedError

    RGBColor Implemented
    PrimitiveValue uses RGBColor
    
    CSSParser uses setProperty instead of addProperty now
    StyleDeclaration, Value, ValueList, PrimitiveValue, RGBcolor
    done comparing spec and module docstrings
    
    made list of TODOs
    
0.55_4 - 040502
    implement \*Rule.cssText setting (UnknownRule not complete)
     
    lexer has no log anymore, simply "logs" everything to the
    resulting tokenlist
    
    cssstylesheet simplified
    
    bugfixes

0.55_3 not released
    cssnormalizer renamed, does not work anyway at the moment   

    implemented StyleRule.cssText setting
    
    cssproperties.Property has new init param raiseExceptions
    similar to the one of CSSParser. does not log yet
    and functionality might change as well
    * what will not change is that you can specify not
    officially specified properties (like moz-opacity etc)
    
    some cleanup in various classes

0.55_2 not released
    tests only

0.55_1 not released
    API CHANGES
        CSSFontFaceRule and CSSPageRule
        style is readonly now

    NEW
        CSSRule
        implementation cssText setting
        improved docstrings
    
    CSSCharsetRule, CSSFontFaceRule, CSSFontFaceRule, CSSImportRule, CSSSMediaRule, CSSPageRule, CSSStyleRule, CSSUnknownRule
        use CSSRule implementation
    CSSCharsetRule
        uses codecs module to check if valid encoding given
    CSSImportRule
        new property styleSheet, always None for now

    simplified and cleaned up sources
    some bugfixes
    
    added tests
        test_cssrule
        test_csscharsetrule, test_cssfontfacerule, test_cssimportrule,
        
        test_mediarule, test_stylesheetrule, test_unknownrule
            subclass test_cssrule now
    improved unittests
        test_cssstylesheet import problem removed

0.55b not released
    start implementation StyleRule.cssText setting

0.54 not released
    API CHANGES
        Comment.cssText contains comment delimiter
        attribute text of Comment private now, renamed to _text
        ALPHA new StyleSheet.cssText property (not in W3C DOM)

    BUG FIXES
        Commentable checked only for str, not unicode. now both
        Parser did not raises all errors, might still not do (s. a.)

    added unittest for __init__ module

0.53 - 040418
    !cssnormalizer does not work in this version - on hold for 1.0

    new cssunknownrule.UnknownRule (moved out of module cssrule)
    parser now creates Unknown At-Rules in the resulting StyleSheet. they
    are no longer just dumped and reported in the parser log.

0.52 - 040414
    !cssnormalizer does not work in this version - on hold for 1.0

    whitespace in comments will be preserved now
        added unittest

0.51 - 040412
    !cssnormalizer does not work in this version - on hold for 1.0

    API CHANGES
    cssrule.SimpleAtRule DEPRECATED and empty
    cssmediarule.MediaRule init param "medias" renamed to "media"
    use subclasses of CSSRule (CharsetRule, ImportRule,
    FontFaceRule or PageRule) instead
    StyleRule constructor can be called with arguments (again...)
    Comment attribute "comment" renamed to "text"

    implemented at least partly almost all DOM Level 2 CSS interfaces now
    so the API should be more stable from now on
    
    new statemachine and lexer helper classes for parsing
    complete rewrite of CSSParser
    CSSParser and lexer put all error messages in a log now
    you might give your own log for messages
    CSSParser might be configured just to log errors or to raise
    xml.dom.DOMExceptions when finding an error

0.41 - 040328
    !cssnormalizer does not work in this version - on hold for 1.0

    API CHANGES
    StyleSheet.getRules() returns a RuleList now
    class Selector removed, integrated into Rules now
    
    moved most Classes to own module
        StyleSheet, StyleRule, MediaRule, ...

0.40a - 040321
    !cssnormalizer does not work in this version
    
    API CHANGES:
    cssbuilder.RuleList subclasses list
    cssbuilder.Selector moved to cssrules
    attribute style of class StyleRule made private (_style)
    removed StyleRule.clearStyleDeclaration 
    attribute selectorlist of class Selector renamed to _selectors and made private

    NEW:
    MediaList class 

    moved tests to directory test

    made a dist package complete with setup.py
        
        
0.31 - 040320
    !cssnormalizer does not work in this version

    API CHANGES:
    StyleDeclaration.addProperty is now DEPRECATED
    use StyleDeclaration.setProperty instead

    removed CSSParser.pprint(). use CSSParser.getStyleSheet().pprint() instead
        (a StyleSheet object had a pprint method anyway)

    replaced cssutils own exceptions with standard xml.dom.DOMException 
        and subclasses
        !catch these exceptions instead of CSSException or CSSParserException

    moved internal lists (e.g. StyleSheet.nodes list) to private vars
        StyleSheet._nodes
        !please use methods instead of implementation details
    
    
    removed cssexception module
    removed csscomment module, classes now directly in cssutils

    more unittests, start with python cssutils/_test.py
    
    more docs

    integrated patches by Cory Dodt for SGML comments and Declaration additions
    added some w3c DOM methods 


0.30b - 040216
    severe API changes
    renamed some classes to (almost) DOM names, the CSS prefix of DOM names is ommited though
    
    renamed are
        - Stylesheet TO StyleSheet
        - Rule TO StyleRule
        - AtMediaRule TO MediaRule
        - Declaration TO StyleDeclaration
        
    the according methods are renamed as well
    
    class hierarchy is changed as well, please see the example
    
    classes are organized in new modules
    

0.24_1 - 040214  
    legal stuff: added licensing information 
    no files released

0.24 - 040111   
    split classes in modules, has to be cleaned up again

0.24b - 040106  
    cleaned up cssbuilder
        - Comment now may only contain text
            and no comment end delimiter. 
            (before it had to be a complete css 
            comment including delimiters)
        - AtMediaRule revised completely
            validates given media types
            new method: addMediaType(media_type)
            
    cssparser updated to new cssbuilder interface and logic
    started unittests (v0.0.0.1..., not included yet)
    
    
0.23 - 031228   
    new CSSNormalizer.normalizeDeclarationOrder(stylesheet)
    
    cssbuilder: added methods needed by CSSNormalizer
    
    CSSParser.parse bugfix


0.22 - 031226   
    CSSParser: 
            added \n for a declaration ending in addition to ; and }
    cssbuilder:
        docstrings added for @import and @charset
        support build of a selector list in a rule


0.21 - 031226   
    cleaned up docstrings and added version information

0.20 - 031224   
    complete rewrite with combination of parser and builder classes

0.10 - 031221   
    first version to try if i can bring it to work at all
    only a prettyprinter included, no builder

