changelog
=========
:Version: $Id: CHANGELOG.txt 1333 2008-07-09 13:27:04Z cthedot $

.. contents::

known issues
------------
- ``CSSStyleSheet.cssText`` is a serialized byte string (**not** unicode string) currently. This may change in the future.

- although cssutils tries to preserve CSS hacks not all are (and some - mainly syntactically invalid ones - will probably never be). The following hacks are known to **not** be preserved:

  star hack (without any whitespace)
    ``*html`` syntactically invalid
  star7 hack (without any whitespace)
    ``html*#test-span`` (IMHO invalidated by the missing WS between html and "*")

  The main problem for cssutils users is that some stylesheets in the wild are not parsable without loosing some information, a pretty print for these sheets is simply not possible with cssutils (actually with hardly any css parser...).

  Generally **syntactically valid stylesheets** should be preserved completely (otherwise it will be a bug in cssutils itself). Invalid stylesheets will probably loose some information like to above ``*html`` hack. Most of these hacks may be rewritten while still be working, e.g. ``* html`` should work same to ``*html``. Until cssutils 0.9.5b2 the invalid IE-specific CSS hack using ``$propertyname`` was preserved but its usage was already discouraged (and if e.g. specifying ``color`` and ``$color`` these properties are **not the same** for cssutils (but are for IE...).
  **These kind of invalid hacks are not kept during parsing anymore since cssutils 0.9.5b3!**
  In almost any case it is possible to use at least syntactically valid CSS while still working around different browser implementations.

- The ``seq`` attribute of most classes does not hinder you to add invalid items. It will probably become readonly. **Never write to it!**

   **Content of ``seq`` will most likely change completely, seq is more of an internal property and should not be used in client code yet**

- Properties are not bound to any CSS Version, so all properties are generally handled and kept. So effectively properties are *NOT* as described in  http://www.w3.org/TR/CSS21/syndata.html#parsing-errors "Illegal values".

    There is the option ``cssutils.ser.prefs.validOnly`` which is used to keep valid (based on CSS 2 valid) properties only. Problem is that current stylesheets use quite a few properties (like e.g. ``opacity``) or property values (like ``display: inline-block``) which are more or less standard but not yet *official*. There is currently no option to specify a version for which properties with which valid values should be used in cssutils. At the moment warnings will be emitted which unfortunately also go for the aforementioned *newer* properties or values.

    There is the plan to be able to *register* custom properties or values but this is just a plan for now...

- ``CSS2Properties`` not implemented completely (setting a shorthand property does not set related properties like setting margin does not set margin-left etc). Also the return values are not as defined in the specification as no normalizing is done yet. (maybe 0.9.6 but again as CSSOM defined something else this may change)

- ``CSSValue``, ``CSSValueList``, and ``CSSPrimitiveValue`` and the relevant methods/properties ``Property.cssValue`` and ``CSSStyleDeclaration.getPropertyCSSValue`` are more or less *DEPRECATED* and will probably be replaced with interfaces defined in CSSOM. For now use the properties and methods that handle values as simple strings. As the aforementioned classes are not hardly that useful this should not be a big problem but please beware if you use or have used them. If you think this a bad idea please let me know!

   Some methods of ``css.CSSPrimitiveValue`` and subclasses ``Rect``, ``Counter`` and ``RGBColor`` are not implemented. As CSSOM defines a completely different DOM for Property values they may never be implemented as defined in DOM Level 2. Actually the current implementation of ``CSSValue``, ``CSSValueList``, and ``CSSPrimitiveValue`` will probably be completely replaced/refactored with suggestions from CSSOM.

- not all Comments reply to preference ``keepComments``, some will probably survive if set to ``False``


0.9.x
-----
HEAD

0.9.5rc1 080709
    - **API CHANGE/FEATURE**: ``The cssutils.log`` may be partly used like a standard logging log. The following methods are available: ('setLevel', 'getEffectiveLevel', 'addHandler', 'removeHandler') as well as all "messaging" calls like 'error', 'warning' etc.

      Therefor ``cssutils.log.setloglevel`` has been *DEPRECATED* and should be used via ``cssutils.log.setLevel``. The old method is still available though.

      ``cssutils.log.setlog`` has been renamed to ``cssutils.log.setLog`` but is still available but *DEPRECATED* too.

    - **FEATURE**: All three decoders in the codec now have an additional ``force`` argument. If ``force`` is false, the encoding from the input will only by used if is is detected explicitely via BOM or @charset rule.

    - **FEATURE**: ``cssparse`` script has new option ``-m --minify`` which results in the parsed CSS to be serialized minified

    - **FEATURE**: ``CSSCapture`` and ``csscombine`` are now available not only as standalone scripts but also via ``cssutils.script.CSSCapture`` and ``cssutils.script.csscombine`` repectively so you can use them programmatically now.

    - **BUGFIX**: A space after @rule keyword is added when serializing minified something like ``@media all{}``. Until now it was ``@mediaall{}`` which is recognized by Safari only and may not be valid at all.

    - **BUGFIX**: Properties of rules set via ``css.CSSStyleSheet.add`` or ``.insert`` were not set properly, e.g. ``parentStyleSheet`` or the stylesheet handling of new @import rules was buggy.

    - BUGFIX: Encountering OSError during resolving @import does not throw an error anymore but the resulting CSSImportRule.styleSheet will have a value of ``None``. OSError will probably only happen when using ``parseFile``.

    - **BUGFIX/IMPROVEMENT**: A style sheet with ``href == None`` (e.g. parsed with ``parseString()`` or build completely from scratch) uses ``os.getcwd()`` as its base href now to be able to resolve CSSImportRules.

    - **BUGFIX/IMPROVEMENT**: Rewrote ``csscombine`` script which should be much more stable now and handles namespaces correctly. Nested imports are still not resolved yet but this may come in the next release.

    - BUGFIX/IMPROVEMENT: Added catching of WindowsError to default fetcher (e.g. is a file URL references a file not present).

    - **BUGFIX/CHANGE**: Redone ``csscapture`` script. A few minor method changes (parameter ``ua`` of ``capture`` has been replaced by init parameter) and lots of internal improvement has been done.

    - CHANGE: ``CSSStyleSheet.add(rule)`` simply appends rules with no specific order in the sheet to the end of it. So e.g. COMMENTs, STYLE_RULEs, etc are appended while rules with a specific place are ordered-in as before (e.g. IMPORT_RULE or NAMESPACE_RULE). Until now rules of a specific type like COMMENTs were ordered together which does not really make sense. The ``csscombine`` script needs this functionality and the resulting combined sheets should be more readable and understandable now.

    - CHANGE: Default URL fetcher emits an ERROR instead of a warning if finding a different mine-type than ``text/css``.

0.9.5b3 080605
    - **API CHANGE**: ``parse()`` is *DEPRECATED*, use ``parseFile()`` instead. I know this should not happen in a release already in beta but better now than later and currently both ways are still possible.

    - **FEATURE**: CSSStyleDeclatation objects may be used like dictionaries now. The value during setting a property may be a single value string or a tuple of ``(value, priority)``::

            >>> style = css.CSSStyleDeclaration()
            >>> style['color'] = 'red'
            >>> style.getProperties()
            [cssutils.css.Property(name='color', value=u'red', priority=u'')]
            >>> del style['color']
            >>> style['unknown'] = ('value', 'important')
            INFO    Property: No CSS2 Property: 'unknown'.
            >>> style.getProperties()
            [cssutils.css.Property(name='unknown', value=u'value', priority=u'impor
            tant')]
            >>> del style['never-set'] # does not raise KeyError but returns u'' like removeProperty()
            >>>

    - **FEATURE**: While reading an imported styleSheet all relevant encoding parameters (HTTP headers, BOM/@charset, etc) are used now as defined in http://www.w3.org/TR/CSS21/syndata.html#charset

        Additionally a given parameter ``encoding`` for ``parseString``, ``parseFile`` and ``parseUrl`` functions/methods **overrides** any detected encoding of read sheet like HTTP information or @charset rules. Useful if e.g. HTTP information is not set properly. The given ``encoding`` is used for **all** imported sheets of the parsed one too! This is a cssutils only addition to the rules defined at http://www.w3.org/TR/CSS21/syndata.html#charset.

    - **FEATURE**: A custom URL fetcher may be used during parsing via ``CSSParser.setFetcher(fetcher)`` (or as an init parameter). The so customized parser is reusable (as all parsers are). The fetcher is called when an ``@import`` rule is found and the referenced stylesheet is about to be retrieved.

      The function gets a single parameter

      ``url``
          the URL to read

      and MUST return ``(encoding, content)`` where ``encoding`` normally is the HTTP charset given via a Content-Type header (which may simply omit the charset though) and ``content`` being the (byte) string content. The Mimetype of the fetched ``url`` should be ``text/css`` but this has to be checked by the fetcher itself (the default fetcher emits an ERROR (from 0.9.5 before a WARNING)  if encountering a different mimetype).
      The content is then decoded by cssutils using all encoding related data available.

        Example::

            def fetcher(url):
                return 'ascii', '/*test*/'

            parser = cssutils.CSSParser(fetcher=fetcher)
            parser.parse...

      To omit parsing of imported sheets just define a fetcher like ``lambda url: None`` (A single None is sufficient but returning ``(None, None)`` is more explicit).

      You might also want to define an encoding for each imported sheet with a fetcher which returns a (normally HTTP content-type header) encoding depending on each URL.

    - **FEATURE**: Added option ``-s --string`` to cssparse script which expects a CSS string to be parsed.

    - **FEATURE/BUGFIX**: Parsing of CSSStyleDeclarations is improved. Invalid ``/color: red;color: green`` is now correctly parsed as ``color: green`` now. At the same time the until now parsed but invalid ``$color: red`` (an IE hack) is not parse anymore but correctly dismissed!

      Unknown rules in CSSStyleDeclaration are parsed now. So e.g ``@x; color: red;`` which is syntactically valid is kept completely.

    - **BUGFIX**: ``parseUrl`` does return ``None`` if an error occurs during reading the given URL. Until now an empty stylesheet was returned.

    - **BUGFIX**: Fixed parsing of values like ``background: url(x.gif)0 0;`` (missing space but still valid).

    - BUGFIX: Serializing CSSUnknownRules is slightly improved, blocks are correctly indentet now.

    - **LICENSE**: cssutils is licensed under the **LGPL v3** now (before LGPL v2.1). This should not be a problem I guess but please be aware. So the former mix of LGPL 2.1 and 3 is resolved to a single LGPL 3 license for both cssutils and the included encutils.

    - INTERNAL: Moved tests out of cssutils main package into a tests package parallel to cssutils.

0.9.5b2 080323
    - **API CHANGE**: ``cssutils.parseURL`` has been renamed to ``parseUrl`` for consistency with ``getUrls`` or ``replaceUrls``. Parameter ``href`` (before called ``url``) is the first and mandatory parameter now.

    + **BUGFIX**: Fix the streamreader in the codec: Honor the encoding if one is passed to the constructor instead of trying to detect it from the stream.

    + **BUGFIX**: Reading referenced styleSheet in CSSImportRule did not succeed as no encoding information is passed along. Encoding of referenced sheets is always retrieved via HTTP or from imported sheet itself. Fixed lots of unchecked cases and simplified exception handling when reading a referenced sheet.

    + BUGFIX: Setting ``atkeyword`` of @rules checks if it is a valid keyword for the specific rule. E.g. an @import rule accepts ``@im\port`` but not ``@namespace``.
    + BUGFIX: Fixed setting ``name`` of CSSImportRule. Setting ``name`` other than with a string results in xml.dom.SyntaxErr raised now
    + BUGFIX: ``CSSStyleSheet.type`` with a fixed value of "text/css" and other readonly properties are really readonly now

    - IMPROVEMENT: Added media information to ``__str__`` and ``__repr__`` or CSSStyleSheet.
    - IMPROVEMENT: Added more information to ``__repr__`` of CSSImportRule.
    - IMPROVEMENT: Added ``__repr__`` for ``cssutils.util._SimpleNamespaces`` which is used in a selector repr.

0.9.5b1 080319
    - **API CHANGE**: ``cssutils.css.CSSSStyleSheet.replaceUrls(replacer)`` has been **DEPRECATED** but is available as an utility function so simply use ``cssutils.replaceUrls(sheet, replacer)`` instead. For the why see ``getUrls(sheet)`` below.

    - **API CHANGE/FEATURE**: ``parseString`` has a new parameter ``encoding`` now which is used if a ``str`` is given for cssText. Otherwise it is ignored. (patch by doerwalter)

    - API CHANGE/FEATURE: ``.parse() .parseString()`` and constructor of ``CSSStyleSheet`` have a new parameter ``title`` needed for the cascade (yet to be implemented ;).

       Also the representation of ``CSSStyleSheet`` has been improved.

    + **FEATURE**: Referenced stylesheet in an @import rule is read and parsed now if possible. Therefor the ``href`` given during parsing (parameter ``href`` to the ``parse*`` functions is used. It is also properly set on imported rules. The ``name`` property of the @import rule is set as the imported sheets ``title`` property.

    + **FEATURE**: Added ``cssutils.getUrls(sheet)`` utility method to get all ``url(urlstring)`` values in ``CSSImportRules`` and ``CSSStyleDeclaration`` objects (properties). As this function and the above mentioned ``replaceUrls(sheet, replacer)`` are useful not only for a single sheet but (later) also for a stylesheet list they are not methods of CSSStyleSheet anymore (also because they are not part of the official DOM spec). (patch by doerwalter)

    + FEATURE: Added ``cssutils.parseURL(url, encoding=None, ...)``

    + BUGFIX: Fixes Issue #10, using full ``$LastChangedDate: 2008-07-09 15:27:04 +0200 (Mi, 09 Jul 2008) $`` in source files breaks code for some locales. Now only in a few files this svn:keywords replacement is used and only to a fixed length without the problematic part. In all other files ``$Id: CHANGELOG.txt 1333 2008-07-09 13:27:04Z cthedot $`` is used which also includes simple but sufficient date information.

    + **BUGFIX/IMPROVEMENT**: Handling of trailing content, WS and comments in rules should be more consistent and properly handled now, added tests. Exception is ``CSSCharsetRule`` where no comments are allowed at all.

        **TODO**: check selector of CSSStyleRule

    - TESTS: **Tests need ``minimock`` now!** Install with ``easy_install minimock``

    + DOCUMENTATION: Improved docs a bit.

    - **LICENSE**: The included `encutils <http://cthedot.de/encutils/>`__ has been updated to version 0.8.2 with a compatible LGPL license. `restserver.py <http://cthedot.de/restserver/>`__ has been updated to version 2.1 which is in the public domain now (no Creative Commons license anymore). So only a single license (the LGPL) is used throughout cssutils now. If you have other licensing needs please let me know.


0.9.5a4 080222
    - **API CHANGE**: ``.wellformed`` replaces ``.valid`` for most classes. This is more an internal value so should be used carefully anyway. Some classes still have both, notably ``Property`` and ``CSSValue``. Also removed ``Preferences.removeInvalid`` which was deprecated for some time now and made not really sense anyway.

    - API CHANGE: Removed ``cssutils.ser.prefs.wellformedOnly`` which made no sense at all. It probably was not used in client code anyway. cssutils serializes wellformed (not necessarily valid) stylesheets only (hopefully ;).

    - API CHANGE: Removed constructor parameter ``css.CSSImportRule(hreftype=...)`` which made no sense really. The type of href is still retained if ``css.CSSImportRule.cssText`` is set (e.g. for ``@import "a-str";`` it is "string" and for ``@import url(an-uri);`` it is "uri". How it is serialized is defined in the serializer anyway (``cssutils.ser.prefs.importHrefFormat`` "string", "uri" or None which then uses the one in each @import rule or defaults to "uri") so it made no sense to have it hear too. It still may be used but generally should not.

    + **FEATURE**: Defining a namespace with a prefix but an empty namespaceURI is not allowed in XML 1.0 (but in XML 1.1). It is allowed in CSS and therefor also in cssutils.

      **ATTENTION**: CSS differs from XML 1.0 here!

    + **FEATURE**: Added property ``css.CSSImportRule.name`` and ``css.CSSMediaRule.name`` as decribed in http://www.w3.org/TR/css3-cascade/#cascading. It is parsed, serialized and available in this new property now. Property ``name`` is a constructor parameter now too.

    + **FEATURE**: ``css.UnknownRule`` is now parsed properly and checked for INVALID tokens or if {}, [] or () are not nested or paired properly. CSSUnknownRule is removed from CSSOM but in cssutils it is and will be used for @rules of programs using extensions, e.g. PrinceXML CSS. It is not very usable yet as no actual properties except ``atkeyword``, ``cssText`` and ``seq`` are present but at least it is syntactically checked properly and I hope serialized similar to other rules. This has been completely rewritten so may contain a few bugs so check your serialized sheets if you use non-standard @rules.

    - **BUGFIX**: Improved escaping. Fixed cases where e.g. an URI is given as ``url("\"")``. Also escapes of delimiters in STRINGs is improved. This is used by ``CSSImportRule`` or ``CSSNamespaceRule`` among others. All STRING values are serialized with ``"..."`` (double quotes) now. This should not be a problem but please note that e.g. a ``CSSValue`` may be slightly different now (but be as valid as before).

    - **BUGFIX**: Fixed serialization of namespaces in Selector objects. Actually all possible namespaced selectors should be preserved now:

        ``*``
            any element or if a default namespace is given any element in that namespace
        ``a``
            all "a" elements or if a default namespace is given "a" elements in that namespace
        ``|*``
            any element in the no namespace (the *empty namespace*)
        ``|a``
            "a" elements in the no namespace (the *empty namespace*)
        ``*|*``
            any element in any namespace including the no namespace
        ``*|a``
            "a" elements in any namespace including the no namespace
        ``p|*``
            any element in the namespace defined for prefix p
        ``p|a``
            "a" elements in the namespace defined for prefix p

    - **BUGFIX**: Default namespace is no longer used by attribute selectors.

    + CHANGE: ``CSSNamespaceRule`` implements http://dev.w3.org/csswg/css3-namespace/ now. Giving the namespaceURI as an URI token (``url("uri")``) is no longer deprecated so no warning is emitted any longer.

    - IMPROVEMENT: Started refactoring rules to have ``wellformed`` property and serializing included comments better.

    - IMPROVEMENT: Added simple testtool for functional tests in /examples plus lots of smaller bugfixes, improvements and refactorings

0.9.5a3 080203
    - **API CHANGE: Refactored and fixed namespace handling**
        Aim was to prevent building invalid style sheets. therefor namespaces must be checked e.g. when adding a new ``Selector`` etc. This probably is not fixed for all cases but much better now than before.

        - added ``CSSStyleSheet.namespaces`` which is a mapping of ``prefix: namespaceURI`` and mirrors all namespaces as defined in @namespace rules. New Namespaces may also be set here as well as prefixes changed.
        - if more than one ``CSSNamespaceRule`` with the same ``namespaceURI`` is set only the last one will be kept. The ``prefix`` of that rule is used.
        - ``CSSNamespaceRule.namespaceURI`` is readonly now, it can only be set in the constructor (needed to prevent an invalid sheet when changing this uri)
        - Namespaces used in a Selector or SelectorList or even a CSSStyleRule while these are not attached to a CSSStyleSheet (which would contain the necessary CSSNamespaceRules) are kept internally. All these classes accept for parameter ``selectorText`` (or ``cssText`` for CSSStyleRule) a tuple of ``(string-to-parse, dict-of-namespaces)`` now while not attached to a style sheet. If attached ``dict-of-namespaces`` is ignored as the namespaces of the relevant style sheet are used. If you need to set e.g. a new selector within a yet undefined namespace, set the namespace in the style sheet first simply by setting e.g. ``sheet[prefix] = namespaceURI``
        - removed ``CSSStyleSheet.prefixes``
        - removed ``Selector.prefixes``

    - **API CHANGE**: ``parentRule`` and ``parentStyleSheet`` of all CSS rules are now readonly to prevent building illegal style sheets.

    - **API CHANGE**: Changed order of constructor parameters for ``CSSStyleDeclaration``. Named parameters SHOULD be used anyway but be careful if you used ordered ones here!

    * **FEATURE**: ``CSSStyleSheet`` and ``CSSMediaRule`` are iterable now. Both iterate on their ``cssRules``. (Internally generators are used.)

    * **FEATURE**: added convinience method ``CSSStyleSheet.add(rule)``  which behaves exactly like ``.insertRule(rule, inOrder=True)``. So rules are added to the approprite position in a style sheet. E.g a namespace rule if put after any @import but before other rules like style or font-face rules.

    * **FEATURE**: added parameter ``inOrder=False`` to method ``CSSStyleSheet.insertRule`` which inserts a given rule to its proper hierarchy. Parameter ``index`` is ignored in this case but the resulting index is properly returned.

    * FEATURE: added convinience method ``CSSMediaRule.add(rule)`` which behaves exactly like ``.insertRule(rule)`` (there is no parameter "inOrder" here as no invalid order may be build in CSS 2.1 or 3).

    * FEATURE: Added ``Selector.parentList`` which contains a reference to the containing ``SelectorList``. Needed (at least) to process namespaces properly.

    + **BUGFIX**: ``CSSMediaRule.insertRule`` setting with a rule string fixed

    + **BUGFIX**: ``*.parentStyleSheet`` and ``*.parentRule`` where * is any CSSRule is properly set now

    + **BUGFIX**: ``CSSStyleDeclatation.getPropertyPriority(p)`` returns ``important`` (without the ``"!"``!) or the empty string now (see http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration). Same goes for ``Property.priority`` which is not in CSSOM but cssutils only.

        (``Property._normalpriority`` has been removed, the normalized value that was available here is now in ``Property.priority``. The literal priority value is available in ``Property.literalproperty`` now (analog to ``Property.literalname``). All these values probably should not be used by client code anyway but may be helpful when using CSS hacks.)

    + BUGFIX: Changed serialization of combinators in ``Selector`` according to http://dev.w3.org/csswg/cssom/#selectors, e.g. ``a>b+c~d e`` serializes as ``a > b + c ~ d e`` now (single spaces around +, > and ~). A new serializer preference ``selectorCombinatorSpacer = u' '`` has been added to overwrite this behaviour (which is set to ``u''`` when using the CSS minifier settings)

    + BUGFIX: Some minor fixes including some reference improvements

    - IMPROVEMENT: csscombine is available via ``from cssutils.scripts import csscombine`` now (not directly in cssutils though!). Some optimizations and comments added.


0.9.5a2 080115
    + **BUGFIX**: Serializing a ``CSSStyleDeclaration`` did not include the effective properties but the last property if set multiple times in a single declaration and preferences ``keepAllProperties == False``.

    + BUGFIX: Fixed parsing of last remaining example in CSS spec ``color:red; color{;color:maroon}; color:green`` which now correctly parses ``color: green``

    + BUGFIX: ``CSSStyleDeclaration.__contains__(property)`` uses not the literal but the normalized name (``Property.name``) to check if a property is set in this declaration now

    + BUGFIX: ``CSSStyleDeclaration.getProperties(all=True)`` failed if comments were present

0.9.5a1 080113
    + **API CHANGE**: ``Property.name`` is now the same as ``Property.normalname`` which is DEPRECATED now. To access the literal name (the value which was available in ``name`` until now) use ``Property.literalname``. For most cases where a property name is used the new behaviour makes more sense, therefor the change.

        **Do not use ``normalname`` anymore, it will probably be removed for release 1.0.**

        NEW since 0.9.5::

            p = Property(ur'c\olor', 'red')
            p.name == ur'color'
            p.literalname == ur'c\olor'
            # DEPRECATED: p.normalname == ur'color'

        OLD until 0.9.5::

            p = Property(ur'c\olor', 'red')
            p.name == ur'c\olor'
            p.normalname == ur'color'

    + **API CHANGE**: iterating over ``css.CSSStyleDeclaration`` yields now *effective* properties only and not *all* properties set in the declaration. E.g. from ``color: red; c\olor: green`` only one Property is returned which has the value ``green``. To retrieve *all* properties use ``CSSStyleDeclaration.getProperties(all=True)``. Reason for this change is that for most cases the new default makes more sense.

    - **FEATURE**: ``css.CSSStyleDelcaration`` supports ``in`` now. Expected is a Property or a name of a property which is checked if already in the style declaration

    - **FEATURE**: ``css.Selector`` has a **readonly** property ``specificity`` now which is calculated as described at http://www.w3.org/TR/css3-selectors/#specificity

      **ATTENTION**: changing the Selector by changing its property ``seq`` does **not** update the specificity! ``Selector.seq.append`` has been made private therefor and writing to ``seq`` **not** be used at all!

    - **FEATURE**: Added ``css.CSSStyleDeclaration.getProperty(name, normalize=True)`` which returns the effective Property object for ``name``.

    - FEATURE: Implemented http://csswg.inkedblade.net/spec/css2.1#issue-23, URI may be ``URL(...)`` or ``u\r\6c(...)`` now

    + **BUGFIX**: ``CSSStyleDeclaration.removeProperty(name, normalize=True)`` removes all properties with given ``name`` now and returns the effective value. If ``normalize==False`` removes only properties with ``name=Property.literalname`` and also only returns the effective value of the unnormalized name.

    + **BUGFIX**: Priority of Properties is acknowledged by all methods of ``css.CSSStylesDeclaration`` now.

    + **BUGFIX**: Fixed serializing of strings like "\\a", "\\22" and '\\27' in @import urls, selectors and values. **func("string") is not yet fixed!!!**

    - CHANGE: ``CSSValueList`` does not emit warnings for shorthand properties anymore. Nevertheless these may be invalid!

    - IMPROVEMENT: ``CSSStyleDeclaration`` and some minor other parts refactored

0.9.4b1 071229
    - **FEATURE**: Added ``csscombine`` script which currently resolves @import rules into the input sheet. No nested @imports are resolved yet and @namespace rules do not work yet though!

    - FEATURE: ``css.CSSStyleSheet.insertRule(rule, index)`` accepts now a ``css.CSSRuleList`` in addition to a ``css.CSSRule`` object or a CSS string. Useful if you like a combine a complete sheet into an existing one.

    + **BUGFIX**: Serializing escape sequences add a single SPACE after each escape. This was not present until now so a sequence like "\\74 a" did come out as "\\000074a" which was not as intended. Also as a SPACE is inserted in any case all escapes are not padded to 6 digits anymore but are only as long as needed.

    + **BUGFIX**: Handling of illegal selectors is now same as the W3C CSS validator (and according the selector spec - I hope ;). Illegal selectors result the complete rule being dropped. Fixed are the following (edge) cases:

      ``a/**/b``
        Meant was probably a space between a and b (plus maybe the comment) but it MUST be inserted. IE and Safari nevertheless seem to parse this rule as ``a b`` so as if a space would be present. cssutils now parses this selector as intented by the spec as ``ab``.
      ``a*b``
        Again spaces around the UNIVERSAL ``*`` were probably meant by the author. IE and Safari seem to parse this **invalid** selector as ``a b``. cssutils ignores this rule completely!

    + BUGFIX: ``css.CSSRuleList`` is still a Python list but setting methods like ``__init__``, ``append``,     ``extend`` or ``__setslice__`` are added later on instances of this class if so desired. E.g. CSSStyleSheet adds ``append`` which is not available in a simple instance of this class! This has been changed as no validation is possible in CSSRuleList itself.

    - CHANGE: Unknown media type in a MediaQuery (e.g. ``@media tv, radio``) does emit WARNING instead of ERROR now.

    + IMPROVEMENT: Added better ``str`` and ``repr`` to cssutils.serializer.Preferences

    + IMPROVEMENT: Added position information to some error reportings (Property, CSSMediaRule

0.9.4a4 071202
    - **FEATURE**: Implemented ``css.CSSFontFaceRule``.

    - **FEATURE**: Added ``css.CSSStyleSheet.encoding`` which reflects the encoding of an explicit @charset rule. Setting the property to ``None`` removes an @charset rule if present and sets the encoding to the default value 'utf-8'. Setting a value of ``utf-8`` sets the encoding to the default value too but the @charset rule is explicitly added.

      Effectively this removes the need to use ``css.CSSCharsetRule`` directly as using this new property is easier and simpler.

      (A suggestion in the `CSSOM <http://dev.w3.org/csswg/cssom/#the-csscharsetrule>`_ but not yet resolved. IMHO it does make sense so it is present in cssutils. ``css.CSSCharsetRule`` remains though if you really *want* to use it).

    + **BUGFIX/IMPROVEMENT**: ``css.SelectorList`` and ``stylesheets.MediaList`` have (Python) list like behaviour partly but are *directly not lists anymore* (which did not work properly anyway...). The following list like possibilities are implemented for now:

      - ``item in x`` => bool
      - ``len(x)`` => integer
      - get, ``del`` and set ``x[i]``
      - ``for item in x``
      - ``x.append(item)``

      The DOM additional methods and properties like ``length`` or ``item()`` are still present (and also will be in the future) but the standard Python idioms are probably easier to use.

      ``stylesheets.StyleSheetList`` and ``css.CSSRuleList`` are the only direct lists for now. This may change in the future so it is safer to also use the above possibilities only for now.

    + BUGFIX: Fixed handling of "\\ " (an escaped space) in selectors and values.

    + BUGFIX: ``!important`` is normalized (lowercase) now

    - IMPROVEMENT: Some error messages have been changed slightly, mostly values are given with their Python representation and not the actual values.
    - IMPROVEMENT: The setup process of cssutils has been adapted to suggestions at http://jimmyg.org/2007/11/08/creating-a-python-package-using-eggs-and-subversion/

    + DOCS: Slight overhaul of docs.

0.9.4a3 071106
    + CSSCapture:
        + **FEATURE**: Added option ``-m, --minified`` to CSSCapture which saves the retrieved CSS files with the cssutils serializer setting ``Preferences.useMinified()``.

        - **BUGFIX**: option '-p' of csscapture is removed as it was not used anyway. A new option ``-r, --saveraw`` has been added which defaults to ``False``. If given saves raw css otherwise cssutils' parsed files.
        - **BUGFIX**: CSSCapture now uses the ``cssutils.parseString`` method so invalid sheets should be saved too. Until now in case of an error the sheet was not saved at all.

    - **BUGFIX/FEATURE**: Handling of unicode escapes should now work propertly.

      The tokenizer resolves any unicodes escape sequences now so cssutils internally simple unicode strings are used.

      The serializer should serialize a CSSStyleSheet properly escaped according to the relevant encoding defined in an @charset rule or defaulting to UTF-8. Characters not allowed in the current encoding are escaped the CSS way with a backslash followed by a uppercase 6 digit hex code point (**always 6 digits** to make it easier not to have to check if no hexdigit char is following).

      This *FEATURE* was not present in any older version of cssutils.

    - **BUGFIX**: Names (of properties or values) which are normalized should be properly normalized now so simple escapes like ``c\olor`` but also unicode escapes like ``\43olor`` should result in the property name ``color`` now

    - **BUGFIX**: Selector did fail to parse negation ``:not(`` correctly
    - **BUGFIX**: CSSValueList treated a value like ``-1px`` as 2 entries, now they are correctly 1.
    - **BUGFIX**: Validation of values for ``background-position`` was wrong.
    - **BUGFIX**: ``CSSPrimitiveValue.primitiveValue`` was not recognized properly if e.g. a CSS_PX was given as '1PX' instead of '1px'.
    - **BUGFIX/CHANGE**: Reporting of line numbers should have improved as ``\n`` is now used instead of ``os.linesep``.

    + **CHANGE**: Invalid Properties like ``$top`` which some UAs like Internet Explorer still are use are preserved. This makes the containing Property and CSSStyleDeclaration invalid (but still *wellformed* although they technically are not) so if the serializer is set to only output valid stuff they get stripped anyway.

      **This may change and also simply may be put in a cssutils wide "compatibility mode" feature.**

    + **CHANGE**: If a CSSValue cannot be validated (no property context is set) the message describing this is set to DEBUG level now (was INFO).

    + IMPROVEMENT: "setup.py" catches exception if setuptools is not installed and emits message

    - DOCS: Added more documentation and also a standalone HTML documentation which is generated from the SVN RST docs.

0.9.4a2 071027
    - **FEATURE**: added ``Preferences.useMinified()`` which sets preferences that a stylesheet will be serialized as compact as possible. Added ``Preferences.useDefaults()`` which resets the serializer preferences. There a few new preferences have been added as well (see the documentation for details as most are hardly useful for normal usage of the library)

    + **BUGFIX**: Fixed parsing of ``font`` value which uses "font-size/line-height" syntax.

    - CHANGE: ``Preferences.keepAllProperties`` defaults to ``True`` now (hardly used but safer if different values have been set which are used by different UAs for example.)

0.9.4a1 071021 (new parser [again])
    - **FEATURE**: Added a new module ``cssutils.codec`` that registers a codec that can be used for encoding and decoding CSS. (http://www.w3.org/TR/2006/WD-CSS21-20060411/syndata.html#q23)

    - **FEATURE**: Added implementation of ``stylesheets.MediaQuery`` which are part of  stylesheets.MediaList. See the complete spec at http://www.w3.org/TR/css3-mediaqueries/ for details.

      Not complete yet: Properties of MediaQueries are not validated for now and maybe some details are missing

    - FEATURE: Implemented ``cssutils.DOMImplementationCSS``. This way it is possible to create a new StyleSheet by calling ``DOMImplementationCSS.createCSSStyleSheet(title, media)``. For most cases it is probably easier to make a new StyleSheet by getting an instance of ``cssutils.css.CSSStyleSheet`` though.

    - FEATURE: cssutils is registered to ``xml.dom.DOMImplementation`` claiming to implement CSS 1.0, CSS 2.0, StyleSheets 1.0 and StyleSheets 2.0. This is probably not absolutely correct as cssutils currently is not a fully compliant implementation but I guess this is used very rarely anyway.

    + **API CHANGE**: ``CSSNamespacerule.uri`` is renamed to ``CSSNamespaceRule.namespaceURI`` which is defined is CSSOM. ``uri`` is deprecated and still available but the constructor parameter is named ``namespaceURI`` in any case now.

    + **API CHANGE**: As ``stylesheets.MediaQuery`` is implemented now all classes using an instance of ``stylesheets.MediaList`` are presented slightly different. Until now a simple list of string was given, now the list contains MediaQuery objects.

    + **API CHANGE**: ``_Property`` has been renamed to ``css.Property`` and is used in context of ``CSSStyleDeclaration`` and ``MediaQuery``. Attribute ``Property.value`` has been *de-deprecated* and may be used normally now (again). The Property constructor has only optional parameters now.

    + **API CHANGE**: Removed experimental class ``SameNamePropertyList`` which was used in ``CSSStyleDeclaration`` and also method ``CSSStyleDeclaration.getSameNamePropertyList``. A new method ``CSSStyleDeclaration.getProperties()`` has been added which is simpler and more useful

    + **API CHANGE**: renamed attribute ``namespaces`` of CSSStyleSheet and Selector to ``prefixes`` as they really are the prefixes of declared namespaces

    - API CHANGE (internal): renamed ``Serializer.do_css_Property`` to ``Serializer.do_Property`` as it is ``Property`` is not in the official DOM, may not stay in package ``css`` and is used by MediaQuery too

    - API CHANGE (internal): renamed ``Serializer.do_CSSvalue`` to ``Serializer.do_CSSValue``

    + BUGFIX: Tantek hack (using ``voice-family``) should work now as SameNamePropertyList is removed and properties are kept in order

    + BUGFIX: Token CHARSET_SYM is now as defined in the CSS 2.1 Errata as literal "@charset " including the ending space.

    - **CHANGE**: A completely new tokenizer and mostly also the parser have been reimplemented in this release. Generally it should be much more robust and more compliant now. It will have new errors and also some slight details in parsing are changed.

    + **DOCS**: Added some docs in reStructuredText format including a basic server to view it as HTML. The HTML may be published as well.

0.9.3a1 - 070905
    - FEATURE: Implemented css.CSSValue, css.CSSPrimitiveValue and css.CSSValueList.

        Not yet implemented are:
            - css.CSSPrimitiveValue.getCounterValue and css. Counter
            - css.CSSPrimitiveValue.getRGBColorValue and css.RGBColor
            - css.CSSPrimitiveValue.getRectValue and css.Rect

        + FEATURE: css.CSSValueList is iterable so may be used in a for loop
        + FEATURE: CSSValue has property ``cssValueTypeString`` which is the name of the relevant ``cssValueType``, e.g. "CSS_PRIMITIVE_TYPE". Mainly useful for debugging.
        + FEATURE: CSSPrimitiveValue has property ``primitiveTypeString`` which is the name of the relevant ``primitiveType``, e.g. "CSS_PX". Mainly useful for debugging.
        + CSSValue has an init Parameter ``_propertyname`` to set a context property for validation. If none is set the value is always invalid. **THIS MAY CHANGE!**

    - FEATURE (**experimental**): CSSStyleDeclaration is iterable now. The iterator returns *all* properties set in this style as objects with properties ``name``, ``cssValue`` and ``priority``. Calling CSSStyleDeclaration.item(index) on the other hand simply returns a property name and also only the normalized name (once). Example::

            sheet = cssutils.parseString('a { color: red; c\olor: blue; left: 0 !important }')
            for rule in sheet.cssRules:
                style = rule.style
                for property in style:
                    name = property.name
                    cssValue = property.cssValue
                    priority = property.priority
                    print name, '=', cssValue.cssText, priority

                # prints:
                # color = red
                # c\olor = blue
                # left = 0 !important

                for i in range(0, style.length):
                    name = style.item(i)
                    cssValue = style.getPropertyCSSValue(name)
                    priority = style.getPropertyPriority(name)
                    print name, '=', cssValue.cssText , priority

                # prints:
                # color = blue
                # left = 0 !important

      **ATTENTION**: This has been changed in 0.9.5, see details there!

    - FEATURE (**experimental**): added ``CSSStyleSheet.replaceUrls(replacer)`` which may be used to adjust all "url()" values in a style sheet (currently in CSSStyleDeclaration and CSSImportRules).

    - FEATURE: added ``CSSStyleDeclaration.getCssText(separator=None)`` which returns serialized property cssText, each property separated by given ``separator`` which may e.g. be u'' to be able to use cssText directly in an HTML style attribute. ";" is always part of each property (except the last one) and can **not** be set with separator!

    - FEATURE: ``href`` and ``media`` arguments can now be passed to ``parse()`` and ``parseString()`` functions and methods. This sets the appropriate attributes on the generated stylesheet objects.

    - FEATURE: CSSMediaRule has an init parameter ``mediaText`` synchronous to CSSImportRule now

    - FEATURE: The ``MediaList`` constructor can now be passed a list of media types.

    - FEATURE: ``CSSRule`` and subclasses have a property ``typeString`` which is the name of the relevant ``type``, e.g. ``STYLE_RULE``. Mainly useful for debugging.

    - FEATURE: ``cssutils.serialize.Preferences`` has a new option ``lineSeparator`` that is used as linefeed character(s). May also be set to ``u''`` for ``CSSStyleDeclareation.cssText'`` to be directly usable in e.g. HTML style attributes

    + API CHANGE (internal): renamed serializers method ``do_stylesheet`` to ``do_CSSStyleSheet``

    - BUGFIX (issue #9): Parsing of empty ``url()`` values has been fixed
    - BUGFIX: Handling of linenumbers in the serializer has been fixed.
    - BUGFIX (minor): removed debug output in CSSStyleDeclaration

    + CHANGE (experimental!): CSSStyleDeclaration.getPropertyCSSValue() for shorthand properties like e.g. ``background`` should return None. cssutils returns a CSSValueList in these cases now. Use with care as this may change later

    + CHANGE: CSSValue default cssText is now ``u""`` and not ``u"inherit"`` anymore

    + CHANGE: ``css.CSSStyleDeclaration.cssText`` indents its property not anymore.

    + CHANGE: ``cssutils.serialize.CSSSerializer`` has been refactored internally to support the lineSeparator option.

    + CHANGE: The Selector and SameNamePropertyList (which might be renamed as it is experimental) class are now available from cssutils.css too.

       **UPDATE: SameNamePropertyList removed in 0.9.4**

    + CHANGE: Tokenizer strips HTML comment tokens CDO and CDC from tokenlist now.

    + CHANGE: Added __repr__ and __str__ methods to most classes. __str__ reports e.g. ``<cssutils.css.CSSImportRule object href=None at 0xaaa870>``, __repr__  e.g. ``cssutils.css.CSSImportRule(href=None, mediaText=u'all')`` which is a valid contructor  for the object in most cases (which might not be complete for all init parameter for all classes like in this case though). The following details are included:

      css
        - CSSStyleSheet shows the title and href
        - CSSCharsetRule shows the encoding
        - CSSCharsetRule shows the cssText (not in __str__ though)
        - CSSImportRule shows the href and the MediaList mediaText
        - CSSMediaRule shows the MediaList mediaText
        - CSSNameSpaceRule shows the prefix and uri
        - CSSPageRule shows the selectorText
        - CSSStyleRule shows the selectorText
        - CSSUnknownRule shows nothing special
        - CSSStyleDeclaration shows the number of properties set for __str__ but an empty CSSStyleDeclaration constructor for __repr__ as showing cssText might be way too much
        - SameNamePropertyList shows the name
        - CSSValue, CSSPrimitiveValue show the actual value for __repr__, some details for __str__
        - CSSValueList shows an __repr__ which is **not** possible to ``eval()`` and some details for __str__
        - _Property shows infos but should be used directly for now anyway!
        - Selector the selectorText

      stylesheets
        - MediaList shows the mediaText

0.9.2b3 070804
    - FEATURE: Script ``cssparse`` handles more than one file at a time now (patch from Issue #6 by Walter Doerwald)

    - BUGFIX: Fixed Issue #7: typo gave AssertionError for selectors like ``tr:nth-child(odd) td{}``
    - BUGFIX: Fixed Issue #5: false warning for certain values for ``background-position`` removed
    - BUGFIX: Report of line/col for any node was not correct if a node contained line breaks itself

    - Quite a few internal optimizations (thanks to Walter Doerwald)
    - Added tests for issues #3 and #4 to tokenizer too

0.9.2b2 070728
    - BUGFIX: Fixed Issue #4, tokenizing of color values like ``#00a`` was buggy (mixture of numbers and characters). Also warnings of invalid property values should be more reliable now (regexes in ``css.cssproperties`` changed).

0.9.2b1 070726
    - BUGFIX: Fixed Issue #3, WS was not handled properly if added to token list by tokenizer

0.9.2a5 070624
    - BUGFIX: Unexpected end of style sheet now handled according to spec for most cases, e.g. incomplete CSSStyleRule, CSSMediaRule, CSSImportRule, CSSNamespaceRule, CSSPageRule.

0.9.2a4 070620
    - BUGFIX (major): no changes to the library, but fixed setup of source dist
0.9.2a3 071018
    - no changes to the library, just optimized setuptools dist

0.9.2a2 070617
    - API CHANGE: removed cssutils.util.normalize function, use static (but private!) method cssutils.util.Base._normalize if absolutely needed which may be change too though
    - API CHANGE (minor): removed ``getFormatted`` and ```pprint`` from various classes which were both DEPRECATED for some time anyway
    - API CHANGE (minor): _Property.value is DEPRECATED, use _Property.cssValue.cssText instead, _Property is defined as private anyway so should not be used directly
    - API CHANGE (minor): removed ``Tokenizer.tokensupto`` which was used internally only

    - CHANGE: Numbers and Dimensions starting with "." like ".1em" in the original stylesheet will be output as "0.1em" with a proceding 0 now.
    - CHANGE: Report of parsing errors have a slightly different syntax now.

    - FEATURE: New ``Preferences.omitLastSemicolon`` option. If ``True`` omits ; after last property of CSSStyleDeclaration

    - BUGFIX: The css validator definition for "num" was wrong, so values like ``-5.5em`` would issue a warning but should be correct
    - BUGFIX: Dimension were not parsed correcly so 1em5 was parsed a "1em" + 5 which should really be one "1em5" were "em5" is an unknown dimension. This had probably no effect on current stylesheets but was a tokenizing error
    - BUGFIX: Parsing of nested blocks like {}, [] or () is improved
    - BUGFIX: Comment were not parsed correctly, now ``/*\*/`` is a valid comment
    - BUGFIX: ``css.Selector`` had a warning which called "warning" which in fact is named "warn". Some other error messages gave token list instead of a more useful string in case of an error, that is fixed as well (CSSComment and CSSValue).

    - IMPROVEMENT: Line number are still not given for all errors reported but for at least some more now
    - IMPROVEMENT: Performance of the tokenizer has been improved, it is now about 20% faster (testing the unittests) which may not hold for all usages but is not too bad as well ;)

0.9.2a1 070610
    - FEATURE: Partly Implemented css.CSS2Properties so you can now use::

        >>> sheet = cssutils.parseString('a { font-style: italic; }')
        >>> style = sheet.cssRules[0].style
        >>> style.fontStyle = 'normal'
        >>> print style.fontStyle
        normal

      Each property can be retrieved from CSSStyleDeclaration object with its name as
      an object property. Names with "-" in it like ``font-style`` need to be called by
      the respective DOM name ``fontStyle``.
      Setting a property value works the same way and even ``del`` which effectively removes a property from a CSSStyleDeclaration works. For details see CSSStyleDeclaration.

      Not implemented are the finer details, see the module documentation of
      cssutils.css.cssproperties.

    - BUGFIX: CSSStyleDeclaration.getPropertyCSSValue returns None for all shorthand properties

    - refactored some parts and added more tests


0.9.1b3 070114
    - **CHANGE** for Serializer preference options:

        new name
        + ``defaultAtKeyword`` instead of ``normalkeyword``
        + ``defaultPropertyName`` instead of ``normalpropertyname``

        camelcase now:
        + ``keepComments`` instead of ``keepComments``
        + ``lineNumbers`` instead of ``linenumbers``

        replaced (see below)
        + ``keepAllProperties`` instead of ``keepsimilarnamedproperties``

    - FEATURE: ``Serializer.prefs.keepAllProperties`` replaces `` ``keepsimilarnamedproperties``:
        if ``True`` all properties given in the parsed CSS are kept.
        This may be useful for cases like::

            background: url(1.gif) fixed;
            background: url(2.gif) scroll;

        Certain UAs may not know fixed and will therefor ignore property 1 but
        an application might simply like to prettyprint the stylesheet without
        loosing any information.

        Defaults to ``False``.

        See examples/serialize.py for an usage example.

    - FEATURE(experimental, might change!):
        ``CSSStyleDeclaration.getSameNamePropertyList(name)``
        Experimental method to retrieve a SameNamePropertyList object which
        holds all Properties with the given ``name``. The object has an
        attribute ``name`` and a list of Property objects each with an actual name,
        value and priority.

        **UPDATE: SameNamePropertyList removed in 0.9.4**

        ``CSSStyleDeclaration.setProperty`` has a new positional parameter
        ``overwrite`` which defines if the property which is set overwrites any former
        value (or values, see ``getSameNamePropertyList``) (default behaviour) or the
        given value is appended to any former value (overwrite=False).
        Useful for cases where a property should have different values for different UAs.

        Example 1: CSS hacks::

            width: 100px; /* wrong box model value for IE5-5.5 */
            padding: 5px;
            w\idth: 90px; /* correct box model value for later browsers */

        Example 2: UA capabilities::

            background: url(2.gif) scroll; /* Fallback for UA which do not understand fixed */
            background: url(1.gif) fixed; /* UA which do know fixed */

    - FEATURE: Reimplemented csscapture, which uses the new serializer preference ``keepAllProperties``

    - BUGFIX(major!): Serializer outputs actual property depending on Property priority out now
        see ``examples/serialize.py``

    - BUGFIX(minor): Parameter ``name`` for `CSSStyleDeclaration.XXX(name)``
      is normalized now, so ``color``, ``c\olor`` and ``COLOR`` are all equivalent


0.9.1b2 070111
    - FEATURE: added ``Serializer.prefs.keepsimilarnamedproperties``:
        if ``True`` all properties with the same normalname but different
        actual names are kept, e.g. color, c\olor, co\lor.
        This is mainly useful to keep a stylesheet complete which uses
        xbrowser hacks as above.

        **UPDATE IN 0.9.1b3!**

    - BUGFIX (minor): ``Serializer.prefs.normalpropertyname`` did not work properly if a property was set 2 times in the same declaration, e.g. ``color: red;c\olor: green`` setting the pref to ``False`` results in ``c\olor: green`` now.
    - BUGFIX (minor): Serializing of CSSStyleDeclaration did not work well when CSSComments were mixed with Properties.


0.9.1b1
    - FUTURE CHANGE: ``readonly`` will be removed from most rules. It is not used anyway, may be readded in a future release

    - CHANGE: order of constructor parameters changed in ``CSSImportRule``. Should be no problem as positional parameters are discouraged anyway
    - CHANGE: cssutils needs Python 2.4 from the release on as it uses the buildin ``set``
    - CHANGE: removed ``CSSMediaRule.addRule`` which was deprecated anyway

    - FEATURE: implemented @page CSSRule including testcases
    - FEATURE: implemented @namespace CSSRule according to http://www.w3.org/TR/2006/WD-css3-namespace-20060828/ with the following changes
        * the url() syntax is not implemented as it may (?) be deprecated anyway
        * added namespace parsing to ``Selector``, see http://www.w3.org/TR/css3-selectors/
        * CSSStyleSheet checks if all namespaces in CSSStyleRules have been declared with CSSNamespaceRules. If not the rule's ``valid`` property is set to ``False`` and the serializer omits it (you may change ``Preferences.removeInvalid`` to change this behaviour).
        * CSSStyleSheet and Selector object have a new propery ``namespaces`` which currently contain declared and used namespace prefixes (!), this may change in the future so use with care if at all.
    - FEATURE: implemented ``CSSRule.parentStyleSheet`` for all rules
    - FEATURE: implemented ``CSSRule.parentRule`` for relevant rules (all allowed in @media)

    - BUGFIX: Set ``parentStyleSheet`` and ``parentRule`` as instance vars in ``css.CSSRule`` instead as class vars
    - BUGFIX: CSSComment raised exception if setting cssText with empty string - fixed

    - DOCS: generated docs with epydoc which are then included in src dist. Source documentation is cleaned up a bit.

    - INTERNAL: Refactored some unittests
    - INTERNAL: implementation based on `DOM Level 2 Style Recommendation <http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/>`_ as opposed to the `Proposed Recommendation <http://www.w3.org/TR/2000/PR-DOM-Level-2-Style-20000927/>`_ now. As there are no main changes I could find this does not make any difference...


0.9.1a1
    - CHANGE, renamed ``Serializer.prefs.srcatkeyword`` to ``Serializer.prefs.normalkeyword``
      which work just the other way round but work as ``Serializer.prefs.normalpropertyname``

    - BUGFIX in css.Selector and added support regarding handling of pseudoclasses (``:x`` or ``:x()``) and pseudoelements ``::x``

    - BUGFIX and refactoring in tokenizer, mostly regarding escape sequences
        * combination of \ and NEWLINE in a string is removed according to spec now

    - added ``Serializer.prefs.normalpropertyname``, if True, property names are normalized if known (``color``), else literal form from CSS src is used (e.g. ``c\olor``). Defaults to ``True``.
    - removed ``Token.literal`` which value is in ``value`` now, normalized value is in ``normalvalue``
    - removed ``Token.ESCAPE``. Escapes are contained in IDENTifiers now.
    - internal change: WS is generally kept by tokenizer now, former normalized value ``u' '`` is hold in ``Token.normalvalue``. Serializer does not use it yet and some classes (like Selector) use normalvalue.

      uses normalized form of @keyword in source CSS if ``True`` (e.g. ``@import``), else literal form in CSS sourcefile (e.g. ``@i\mport``). Defaults to ``True``.



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

    - NEW ``Serializer.prefs.srcatkeyword`` UPDATE see 9.91a1

    - 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 with a new parser (again)
    - 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.8.x
-----

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.6.x
-----

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.5.x
-----

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.4.x
-----

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.3.x
-----

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.2.x
-----

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.1.x
-----
    0.10 - 031221
    first version to try if i can bring it to work at all

    only a prettyprinter included, no builder

