- Consolidated license to simply LGPL 3. (#52)
- Reduced cyclomatic complexity in selector module. (#47)
- Fixed DeprecationWarning with cgi module.
- Remove optional dependency only required on unsupported Python versions. (#48)
- Replace xunit-style setup with pytest fixtures. (#45)
- getPropertyValue now allows specifying a default value. (#42)
- Made URL fetcher lenient to missing metadata.
- Require Python 3.8 or later.
- Made some unreachable tests reachable.
#36: Refactored to restore docs builds without warning-errors.
#35: Updated deprecated usage of cgi module.
#34: Updated deprecated setup/teardown from nose in tests.
Other miscellaneous cleanup and packaging updates.
#14: Added support for custom CSS variables with -- prefix.
Some refactoring.
Substantial code refresh. Ported tests to native pytest.
Enrolled project with Tidelift.
#24: Added Python 3.11 compatibility to tests.
#22: Removed cssutils.tests.basetest.get_resource_filename.
#21: Cleaned up docs so they build without warnings.
Require Python 3.7.
Misc fixes in #10, #15, #17.
#7: Add support for a calc() within a calc().
Minor cleanup.
Restored package version reporting when fetching URLs.
Adopted jaraco/skeleton.
Delinted codebase.
Removed cssutils.VERSION and cssutils.__version__.
Consumers wishing to know the version should use
importlib.metadata.version('cssutils').
New maintainer revives the project and moves hosting with continuous integration testing.
Refreshed packaging.
Project now requires Python 3.6 or later.
Undocumented changes.
Undocumented changes.
(1.0 only cause I was tired of the 0.9.x releases ;)
EXPERIMENTAL: Variable references may have a fallback value now (as implemented in Firefox 29). It is available as
CSSVariable.fallbackand example are:bottom: var(b); color: var(theme-colour-1, rgb(14,14,14)); left: var(L, 1px); z-index: var(L, 1); top: var(T, calc( 2 * 1px )); background: var(U, url(example.png)); border-color: var(C, #f00)FEATURE: (Bitbucket #37) Implemented parsing of
CSSCalcvalues. General syntax is checked but not if operators in calc are actually the right kind like DIMENSION * DIMENSION. Also Values using calc do not validate in cssutils but are actually valid.FIXED Bitbucket #20 and Bitbucket #35 (Test fail CSSParser.parseUrl() error with Python 3.3)
FIXED Bitbucket #21: (almost all) deprecation warning in Py 3.3 fixed.
FIXED Bitbucket #30 (Test failed)
FIXED Bitbucket #33 (well kinda): Added that cssutils is not threadsafe!
- FIXED Bitbucket #34: More complext MediaQueries should be parsable now. A few slight changes in behavior are:
xml.dom.SyntaxErrraised instead ofxml.dom.InvalidCharacterErrfor an unknown media type- removed
handheldmedia type special case (for old Opera).
- BUGFIX: False HASH color values like
#xyzwere not being handled properly (thanks to Teruaki Koizumi)- Fixed Bitbucket #23: Tests do work properly in newer Python (>2.7.1?) version now, old versions will report error. Before this was the other way round but this makes more sense probably
- Fixed Bitbucket #24: rgba color values did not validate properly
- (Jason R. Coombs) Fixed Bitbucket #25: Cssutils installs "tests" package
- Fixed Bitbucket #27: Small magnitude float values serialized incorrectly
- Fixed Bitbucket #28: Standalone semicolons in CSSStyleDeclaration is now simply stripped and does not remove directly following property too
- 0.9.10b1 120428
- REGRESSION: Valid profiles reported by validation may not be right but as these hardly say anything in the real world anyway the advancements in the following bugfixes are probably worth this.
Profiles.validateWithProfilecurrently not working but should be hardly used anyway. As a workaround remove all profiles and add just the ones you want to use for your application - BUGFIX: Profiles have been updated. Multiple profiles can be added via
addProfilesand this is preferred to adding separate profiles withaddProfile. Profiles do check for updated macros now so that e.g. CSS3 Colors defined in a different profile are valid for all properties defined before. This may lead to a reset of all properties and so may be an extremely expensive operation. - BUGFIX: font-family names in profile CSS3_FONTS seem to have been defined wrongly. Family names containing spaces are valid now, even without quotes.
- BUGFIX: for Python 2.5 compatibility (thanks @Jason)
- IMPROVEMENT: Added all X11 color names and corresponding RGBA values
- REGRESSION: Valid profiles reported by validation may not be right but as these hardly say anything in the real world anyway the advancements in the following bugfixes are probably worth this.
FEATURE: Implemented API for
MarginRuleobjects insideCSSPageRule, see http://www.w3.org/TR/css3-page/. You can also use e.g.CSSPageRule['@top-left']to retrieve the MarginRule it it is set etc. All dict like methods should be there. If a margin is set twice or more all properties are merged into a single margin rule. Double set properties are all kept though (see below).FEATURE:
parseStyle()has optional parametervalidate=Falsenow too to disable validation (default is alwaysTrue).FEATURE:
CSSStyleDeclaration.setPropertyhas new optionreplace=True. if True (DEFAULT) the given property will replace a present property. If False a new property will be added always. The difference to normalize is that two or more properties with the same name may be set, useful for e.g. stuff like:background: red; background: rgba(255, 0, 0, 0.5);which defines the same property but only capable UAs use the last property value, older ones use the first value.
- CHANGE: @rules attribute
atkeywordvalue is now normalized. The actual keyword (example@IMPorT) is kept and is optionally reserialized but in the exampleatkeyword == '@import'
- BUGFIX: 'auto' is now an invalid CSSPageRule pagename.
- BUGFIX: Fixed issue for GoogleAppEngine (GAE) which somehow handles codecs differently.
parseUrlshould work now.
- 0.9.8 final 111210
- FEATURE: Feature Request (Bitbucket #4) to be able to disable validation of a stylesheet has been implemented. Add Parameter
validate=Falsefor parsing.
- BUGFIX: Fixed Bitbucket #5 Unicode escaping inside strings. Thanks to Simon Sapin
- BUGFIX: The integer is optional in counter-reset and counter-increment, and not only on the first counter. Thanks to Simon Sapin
- BUGFIX: Fix for unicode replacements by Denis Bilenko, thanks! https://bitbucket.org/cthedot/cssutils/pull-request/1/fix-a-bug-in-regex-which-accidentally
- IMPROVEMENT:
parseStylemoved to CSSParser, thanks to Simon Sapin
- FEATURE: Feature Request (Bitbucket #4) to be able to disable validation of a stylesheet has been implemented. Add Parameter
- 0.9.8a3 110727
- BUGFIX: Fixed validation of
sizeproperty (thanks to Simon Sapin) - BUGFIX: Fixed Issue Bitbucket #55 (thanks to Simon Sapin): outline-color property was missing from validation.
- BUGFIX: Fixed validation of
- BUGFIX: Fixed resolution of encoding detection of a stylesheet which did not use @charset in certain circumstances (mainly when imported sheets use different encoding than importing one which should be quite rare actually).
- FEATURE: Added
URIValue.absoluteUri(thanks to Simon Sapin) - FEATURE: Issue Bitbucket #53 feature request: Added new Preference option
cssutils.ser.prefs.indentClosingBrace. Defines if closing brace of block is indented to match indentation of the block (default) oder match indentation of selector. - FEATURE: Feature request: Added new Preference option
cssutils.ser.prefs.omitLeadingZero. Defines if values between -1 and 1 should omit the 0, like.5px. Minified settings do this, else 0 is kept by default.
- CHANGE (minor): Some error messages have slightly changed due to a simpler compatibility to Python 3. Problem are any
u'...'texts inside error messages which now are simplified, some without and quotes. Changed are e.g. error messages byProperty.
- IMPROVEMENT: Python 3 support. At least the unittests run in Python 2.5, 2.6, 2.7, 3.2 and Jython 2.5.1 now. Both encutils (with support by Fredrik Hedman, thanks!) and cssutils (thanks to Jaraco) and the CSS codec (thanks to Walter Dörwald) seem to work with Python 3 (tested on Python 3.2.1 Win64). Tests use Mock instead of MiniMock now as former is available for Python 2.x and 3.x.
- IMPROVEMENT: Parsing of longer (and probably invalid)
fontorfont-familyvalues was extremely slow due to a very complex regex. This has been changed and parsing of specific stylesheets using these values should be much faster now. (macros[Profiles.CSS_LEVEL_2]['font-family']is gone so if you used this in your own validation modules you need to check the source in profiles.py.) - IMPROVEMENT: Fixed Issue Bitbucket #54 (thanks to Simon Sapin): Short hand like #f80 color value object have correct red, green and blue property values now. Also
hsl()andhsla()colors report (almost) correct values (due to rounding problems). - Source control has moved to bitbucket https://bitbucket.org/cthedot/cssutils. Older Issues are currently still at Google Code, newer at Bitbucket. Please do not use Google Code for new issue reports anymore!
- 0.9.8a2 110611
- BUGFIX: Fixed Issue Bitbucket #59 which showed a rather strange problem with longer space separated lists of font-family values being so slow to actually stop parsing.
- BUGFIX/IMPROVEMENT: Fixed Issue Bitbucket #48.
CSSParser.parseUrl()uses the defined fetcher of this parser for the initial stylesheet at url too and not just the imported sheets from this sheet. - BUGFIX: Fixed Issue Bitbucket #50 which prevented cssutils parsing the acid2.css file correctly. Problem were selectors starting directly with
[class](an attribute selector).
- API CHANGE (major)
(Known) named colors are parsed as ColorValue objects now. These are the 16 simple colors (black, white, etc) and transparent but not all Extended color keywords yet. Also changed
ColorValue.typetoValue.COLOR_VALUE. ColorValue has additional propertiesred, green, blue, alphaandcolorTypewhich is one of IDENT, HASH or FUNCTION for now.
- API CHANGE (minor)
Removed already DEPRECATED
cssutils.parseandCSSParser.parse. Use the more specific functions/methodsparseFile parseString parseUrlinstead.Removed already DEPRECATED
cssutils.log.setlogand.setloglevel. Use.setLogand.setLevelinstead.Removed already DEPRECATED
cssutils.ser.keepUnkownAtRules(note the typo). Use.keepUnknownAtRulesinstead.
- IMPROVEMENT: Added validation profiles for some properties from CSS Backgrounds and Borders Module Level 3, CSS3 Basic User Interface Module, CSS Text Level 3
- mainly cursor, outline, resize, box-shadow, text-shadow
- 0.9.8a1 101212
- API CHANGE (major)
replace CSSValue with PropertyValue, Value and other classes.
- NEW CLASSES:
- :class:`cssutils.css.PropertyValue`
replaces CSSValue and CSSValueList
- is iterable (iterates over all single Value objects which in soruce CSS might be separated by "," "/" or " "
- a comma separated list of IDENT values is no longer handled as a single String (e.g.
Arial, sans-serif)
- :class:`cssutils.css.Value`
replaces CSSPrimitiveValue with separate
valueandtypeinfo (value is typed, so e.g. string for e.g. STRING, IDENT or URI values, int or float) and is base class for more specific values like:- :class:`cssutils.css.URIValue`
replaces CSSPrimitiveValue, additional attribute
uri- :class:`cssutils.css.DimensionValue`
replaces CSSPrimitiveValue, additional attribute
dimension- :class:`cssutils.css.ColorValue`
replaces CSSPrimitiveValue, additional attribute
red,green,blueandalphaTODO: Not yet complete, only rgb, rgba, hsl, hsla and has values use this object and color and alpha information no done yet!
- :class:`cssutils.css.CSSFunction`
replaces CSSPrimitiveValue function, not complete yet
also renamed
ExpressionValueto :class:`cssutils.css.MSValue` with new API
- IMPROVEMENT/CHANGE: Validation of color values is tighter now. Values like
hsl(1, 2, 3)do not validate as it must behsl(1, 2%, 3%). This mostly effects HSL/A and RGB/A notation. - IMPROVEMENT: New Value parsing and API accelerate parsing of style declarations which take about 20-30% less time now. Of course this depends on the complexity of your styles.
- BUGFIX: fixes Bitbucket #41, Bitbucket #42, Bitbucket #45, Bitbucket #46
- PropertyValue.value returns value without any comments now, else use PropertyValue.cssText
- FEATURE:
cssutils.replaceUrls()accepts as first argument a cssutils.css.CSSStyleSheet but now also a :class:`cssutils.css.CSSStyleDeclaration` object, so may be used like the following which is useful when you work with HTML style attributes:
>>> style = cssutils.parseStyle("background-image: url(1.png), url('2.png')") >>> cssutils.replaceUrls(style, lambda url: 'prefix/'+url) >>> print style.cssText background-image: url(prefix/1.png), url(prefix/2.png)(I omitted the validation error message as more than one background-image is not yet defined in the cssutils validator but does parse through without problems)
- FEATURE:
- CHANGE: explicit + of any dimension, percentage of number value is kept now instead of being stripped as if put explicitly in the author SHOULD have meant something ;)
- FUTURE CHANGE: CSSValue and subclasses will most certain not be supported in the next cssutils 0.9.8 version. A simpler and hopefully more robust API is in development. So the next version will have incompatible changes so you might wanna use 0.9.8 from the start if you do anything fancy with CSSValue and related classes.
- 0.9.7b4 101101
- EXPERIMENTAL: CSS function values using
calc(...)should be partly parsable now (as experimental ExpressionValues currently)
- BUGFIX: MS specific values are parsed a bit more reliable if parsing of these values is activated (they probable are syntactically invalid!). E.g.
top: expression(eval(document.documentElement.scrollTop))and also a few values for the MS specificfilterproperty are parsed and reserialized now.
- IMPROVEMENT:
CSSStyleSheet.variablesnow contains all available variable values (from all imported sheets as well as in sheet defined itself)
- EXPERIMENTAL: CSS function values using
- 0.9.7b3 100620
- API CHANGE: Changed parameters of script/utility function
csscombine. - parameter
resolveVariables=Truenow (default wasFalsebefore) minify = Truewill not parse Comments at all. This is not really a change as comments were not kept in a minified stylesheet anyway but this may speed up stylesheet combination a bit
- parameter
- API CHANGE: Changed parameters of script/utility function
- PERFORMANCE/IMPROVEMENT: Added parameter
parseComments=Trueto CSSParser. If parsing withparser = cssutils.CSSParser(parseComments=False).parse...comments in a given stylesheet are simple omitted from the resulting stylesheet DOM. - PERFORMANCE: Compiled productions in cssutils tokenizer are cached now (to clear it use
cssutils.tokenize2._TOKENIZER_CACHE.clear()) which results in a slight performance improvement. Thanks to Amit Moscovich!
- 0.9.7b2 100606
- IMPROVEMENT/BUGFIX: CSSFunction value parameters may contain HASH values like
#fffnow. These are used in experimental properties like-moz-linear-gradient(top,#fff,#fff 55%,#e4e4e4). Fixes Bitbucket #38. - API CHANGE:
cssutils.ser.prefs.resolveVariables == Trueis the default from 0.9.7b2 as CSSVariables are not in any official specification yet and better reflects what you probably want after serializing a stylesheet...
- IMPROVEMENT/BUGFIX: CSSFunction value parameters may contain HASH values like
- 0.9.7b1 100530
API CHANGE: Child objects like the
cssRulesof aCSSStyleSheetorCSSMediaRuleare no longer kept after resetting the complete contents of an object (settingcssText). This should not be expected anyway but if you relied on something like the following please beware:sheet = cssutils.parseString('a { color: red}') initial_rules = sheet.cssRules sheet.cssText = 'b { color: green}' # true until 0.9.6a6: assert sheet.cssRules == initial_rules, but now: assert sheet.cssRules != initial_rulesIMPROVEMENT: Massive speed improvement of handling of CSSVariables of a stylesheet which due to naive implementation was unbelievable slow when using a lot of vars... Should now scale a lot better, about factor 5-20 depending of amount of variables used.
IMPROVEMENT: Fair amount of refactoring resulting in a bit speed improvement generally too
CHANGE: If a CSS variable should be resolved (
cssutils.ser.prefs.resolveVariables == true) but no value can be found a WARNING is logged now. Should be an ERROR actually but as currently lots of "fake" errors are reported would probably hurt more than help. A future release might improve this.BUGFIX: Syntax of value of CSS Fonts Module Level 3
srcproperty now validates if local font name is given with a quoted name, e.g.:src: local('Yanone Kaffeesatz')
- 0.9.7a6 100523
- API CHANGE (major): When setting an objects
cssText(orselectorTextetc) property the underlying object is replaced with a new one now. E.g. if settingcssutils.css.CSSStyleRule.selectorTextthe underlyingcssutils.css.CSSStyleRule.selectorListobject is swapped to a newSelectorListobject. This should be expected but cssutils until now kept the exact same object and changed its content in-place. Please be aware! (Also the strange_absorbmethod of some objects is gone which was used for this.) - API CHANGE (minor): Renamed
cssutils.ser.prefs.keepUnkownAtRulestocssutils.ser.prefs.keepUnknownAtRulesdue to misspelling, see Issue Bitbucket #37. A DeprecationWarning is issued on use. - API CHANGES (minor):
cssutils.css.CSSImportRule.mediaandcssutils.css.CSSMediaRule.mediaare now writable (setting with a string orcssutils.stylesheets.MediaList)- msg level when setting
cssutils.stylesheets.MediaList.appendMediumchanged to INFO (was WARNING) str(cssutils.css.CSSStyleRule)slightly changed
- IMPROVEMENT/BUGFIX: Improved distribution: Egg release should no longer include the tests package, source release still should. Also added dependency package for tests (minimock) and removed documenation txt files from distribution (HTML still included of course). This also fixes Issue Bitbucket #36.
- IMPROVEMENT: cssutils issues a warning if a page selector is not one of the defined in the spec (
:first,:left,:right). - IMPROVEMENT: Refactored quite a lot and added a few tests for variables
- API CHANGE (major): When setting an objects
- 0.9.7a5 100523
- same changes as 0.9.7a6 but release was incomplete :(
- 0.9.7a4 100323
- API CHANGE:
CSSRule.NAMESPACE_RULEactual value has been changed from 8 to 10 (according to the change in the CSSOM spec). The actual integer values SHOULD NOT be used anyway! Please do always use the ``CSSRule`` constants which are present in ALL CSSRule and subclass objects like CSSStyleRule, CSSImportRule etc.! - API CHANGE:
CSSStyleSheet.setSerializerandCSSStyleSheet.setSerializerPrefhave been DEPRECATED. Usecssutils.setSerializer(serializer)or set pref incssutils.ser.prefsinstead. - IMPROVEMENT/CHANGE: Did some minor changes to improve compliance to http://dev.w3.org/csswg/cssom
- MAJOR: :class:`cssutils.css.CSSImportRule.styleSheet` always references a CSSStyleSheet now.
parentStyleSheetof this sheet isNonenow - MINOR: added property
alternateto :class:`cssutils.stylesheets.StyleSheet`, which for now is alwaysFalse - improved handling of encodings during imports (edge cases hopefully not found in the wild ;)
- MAJOR: :class:`cssutils.css.CSSImportRule.styleSheet` always references a CSSStyleSheet now.
FEATURE: Started experimental implementation of CSS Variables
experimental and incomplete
Related details:
- added
cssutils.css.CSSStyleSheet.variableswhich is a :class:`cssutils.css.CSSVariablesDeclaration` containing all available variables in this CSSStyleSheet including the ones defined in imported sheets. cssutils.ser.prefs.resolveVariables == False: If set toTruetries to resolve all variable references and removes any CSSVariablesRules.cssutils.ser.prefs.normalizedVarNames==True: Defines if variable names should be serialized normalized (they are used as being normalized anyway)
- added
- FEATURE: Added new options to
cssutils.script.csscombine: cssText=Noneandhref=Noneto start combination from a css string, which normally needshrefto be able to resolve any imports.resolveVariables=Falsewhich resolves any variables if given the valueTrue
- FEATURE: Added new options to
DOCUMENTATION: Reordered and cleared docs up a bit
- API CHANGE:
- 0.9.7a3 100314
- API CHANGE:
CSSRule.NAMESPACE_RULEactual value has been changed from 7 to 8 (according to the change in the spec). AlsoCSSRule.COMMENThas a value of1001(was-1) andCSSRule.VARIABLES_RULEhas a value of1008(was8) now (being not in the official spec yet anyway but values are now in the open valuespace above 1000). The actual integer values SHOULD NOT be used anyway! Please do always use the ``CSSRule`` constants which are present in ALL CSSRule and subclass objects like CSSStyleRule, CSSImportRule etc.!
- FEATURE: Added
CSSRuleList.rulesOfType(type)which return and iterator the rules of the given type only. May be used on bothCSSStyleSheet.cssRulesorCSSMediaRule.cssRules.typeis one of the constants defined incss.CSSRulelike e.g.css.CSSRule.STYLE_RULE. - FEATURE (strange): IE specific values like
DropShadow(color=#eee, offX=2, offY=1)(andBlur,Shadow) should be parsed and serialized now as anExpressionvalue. I have not tested this deeply and there may be problems but for some common cases theses values should at least survive a parse/serialize with cssutils.
- BUGFIX/IMPROVEMENT: Parser now handles FUNCTION values which themselves contain another FUNCTION as used by PrinceXML CSS like e.g.
prince-link: target-counter(attr(href), page)
- API CHANGE:
- 0.9.7a2 091230
- API CHANGE: Setting a style declarations' property to
Noneor the empty string effectively removes this property from the declaration. See also Issue Bitbucket #32.
- BUGFIX/FEATURE: Fixed Issue 33: URL references (like
url()values) in combined sheets are now adjusted even if sheets are not in the same folder. Only relative paths are adjusted.
- BUGFIX: Fixed parsing of FUNCTIONS in CSSUnknownRule like
@bottom { counter(page) }which raised a false error of a mismatch of parenthesis
- FEATURE: Added parameter
ignoreImportRules=Falsetocssutils.replaceUrlswhich when set toTrueno longer reports URLs from @import rules but property values only (see Issue Bitbucket #33)
- API CHANGE: Setting a style declarations' property to
- 0.9.7a1
- test release only
- 0.9.7a0
- API CHANGE: Replaced init parameter and attribute
css.Selector.parentListwithcss.Selector.parent - API CHANGE (minor): Removed
css.Property.parentStylewhich was deprecated for some times now in favor ofcss.Property.parent
IMPROVEMENT: Massive speed improvement due to changes in internal parsing.
When tried in a real world situation (parsing the stylesheet for my own site inside a simple WSGI based CSS handler) the parser uses ~0.7-0.8s when using cssutils 0.9.6. With cssutils 0.9.7a0 it only needs ~0.21s so only about 1/3 to 1/4 the time...
FEATURE: Parameter index of
CSSStyleSheet.deleteRule(index)andCSSMediaRule.deleteRule(index)may now also be a rule object to be removed from the contained cssRules list.
- INTERNAL: Added
tokenizer.push(). Prodparser uses a global tokenizer now.
- API CHANGE: Replaced init parameter and attribute
- 0.9.6 091007
- BUGFIX: Definition of macro for positivenum in cssutils profiles actually did allow nagative numbers, fixed (thanks to Jason R. Coombs)
- distribution build with distribute instead of setuptools
- 0.9.6b5 090830
- BUGFIX: Issue Bitbucket #30 fixed. Setup from source did not work.
- 0.9.6b4 090829
- BUGFIX: Issue Bitbucket #29 fixed. Double defined namespaces are replaced with a single (the last one) now.
IMPROVEMENT:
cssutils.resolveImportsnow keeps media information when to be resolved @import rule uses these. It wraps the imported rules in an @media rule which uses the same media information from the @media rule in the original sheet.An xml.dom.HierarchyRequestErr may occur if an imported sheet itself contains @imports with media information or other rules which are not allowed in a @media rule like @namespace rules. In that case cssutils cannot resolve the @import rule and logs a WARNING but keeps the original @import.
- 0.9.6b3 090802
- FEATURE: Added parsing support and new profile for details defined in module Fonts http://www.w3.org/TR/css3-fonts/
- new properties:
font-stretch,font-size-adjust - @font-face rules use a different profile for validation now which uses the defined properties only:
font-family font-style font-weightproperties redefined- added
srcandunicode-rangeproperties
- Added
CSSFontFaceRule.valid. A @font-face rule is valid if all font descriptions properties are valid and propertiesfont-familyandsrcare set.
- new properties:
- FEATURE: Added
cssutils.parseStyle(cssText, encoding='utf-8')convienience function which assumes that the given cssText is the content of an HTML style attribute. It returns a :class:`~cssutils.css.CSSStyleDeclaration`. - FEATURE (experimental, request from Bitbucket #27): Added
css.CSSStyleDeclaration.children()which is a generator yielding any known children of a declaration including all properties, comments or CSSUnknownRules. - FEATURE:
CSSStyleDeclaration.insertRulealso accepts aCSSRuleListnow (same asCSSStyleSheetwhich does this for some time now). - FEATURE: Added
CSSStyleDeclaration.keys()method which analoguous to standard dict returns property names which are set in the declaration.
- API CHANGE: Replaced attribute
css.Property.parentStylewithcss.Property.parent(parentStyleis DEPRECATED now). - API CHANGE: Added attribute
parentto all CSSRules. It contains the Parent Node of this CSSRule (currently if a CSSStyleDeclaration only!) or None. - API CHANGE (minor): Removed parameter
profilesfromcssutils.css.Property.validate(). During validation each property checks which profiles to use which normally are all registered profiles in cssutils.profile. Exceptions are @font-face (TODO: and @page) rules which use their specific profile only. To add custom properties or values for the validation of these rules you need to add these toproperties[Profiles.CSS3_FONT_FACE]in modulecssutils.profilesand reregister that profile.
- BUGFIX: Improved child and parent node referencing.
- setting
CSSStyleSheet.cssRulesandCSSMediaRule.cssRulescorrectly updateparentStyleSheet(andparentRule) of contained rules now. Also settingscssRulesshould now work as expected. - setting
css.CSSStyleRule.selectorListwith acss.SelectorListobject uses this new object directly - setting
css.CSSStyleRule.stylewith acss.CSSStyleDeclarationobject uses this new object directly CSSStyleDeclaration.parentRulewas not properly set for CSSStyleRule, CSSPageRule and CSSFontFaceRule.
- setting
- BUGFIX: Parsing of CSSValues with unknown function names with a specific length of 4 or 7 chars were resulting in a SyntaxErr. Also parsing of comma separated list of CSS FUNCTION values works now.
- BUGFIX: Fixed validation problems:
font-family: a b(values with spaces in names without being quoted) are parsed now without emitting an ERROR. These are indeed valid but discouraged and you should use quotes (more than one space is compacted to a single space anyway so rather complicated without quotes)- negative lengths for the
font-sizeproperty are now properly reported as ERRORs
- IMPROVEMENT (minor): cssutils sets the HTTP header
User-Agentnow when fetching sheets over HTTP (with e.g.cssutils.parseUrl).
- CHANGES:
- Refactored predefined
Prodobjects used for parsing ofCSSValue. Also addedPredef.unicode_rangeand renamedCHARtochar. - Removed css3productions which were only used for tests only anyway and which were not up to date at all
- Refactored predefined
FEATURE (experimental): Added support to at least parse sheets with Microsoft only property values for
filterwhich start withprogid:DXImageTransform.Microsoft.[...](. To enable these you need to set:>>> from cssutils import settings >>> settings.set('DXImageTransform.Microsoft', True) >>> cssutils.ser.prefs.useMinified() >>> text = 'a {filter: progid:DXImageTransform.Microsoft.BasicImage( rotation = 90 )}' >>> print cssutils.parseString(text).cssText a{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=90)} >>>This currently is a major hack but if you like to minimize sheets in the wild which use this kind of CSS cssutils at least can parse and reserialize them. Also you cannot reset this change until you restart your program.
These custom CSS FUNCTION names are not normalized at all. Also stuff like
expression(...)which was normalized until now is not anymore.
- 0.9.6b2
- NO RELEASE
- 0.9.6b1 090609
- BUGFIX: Fixed
CSSPageRule.selectorText = ''which does reset the selector now - BUGFIX (minor): Removed false references in a few modules'
__all__list
- IMPROVEMENT: Jython 2.5 (from RC4) runs all tests now but a few changes had to be done:
- exception messages sometimes do have a different format in Jython and Python (but also between Python versions >= 2.5 and < 2.4 ...)
- Jython's
xml.dom.Exceptionmisses attributeargsit seems
- BUGFIX: Fixed
- 0.9.6a4 090509
- API CHANGE: Reverted handling of exceptions (Bitbucket #24) as this did not work with PyXML installed. You may again use
str(e)on any raised xml.dom.Exceptione. Since 0.9.6a0 exceptions raised did raise a tuple of message, line and col information. Now the message alone is raised (again). Line and col information is still available ase.line, e.col.
- BUGFIX: Fixed Bitbucket #22 parsing or actually reserializing of values like
content: "\\" - BUGFIX: All examples at http://www.w3.org/TR/2009/CR-CSS2-20090423/syndata.html#illegalvalues should work now as expected:
- Unknown ATKEYWORD tokens in selectors make these invalid now, see example :
p @here {color: red} - completion of incomplete @media rule like
@media screen { p:before { content: 'Hellodoes work now when parsing with a non raising parser
- Unknown ATKEYWORD tokens in selectors make these invalid now, see example :
- FEATURE: Updated some parts to http://www.w3.org/TR/2009/CR-CSS2-20090423/changes.html#new (most changes decribed there were already done in cssutils)
- updated tokenizer macro
escape - replaced media
auralwithspeech - property
contenthas allowed valuenonenow - property
background-positionallows mixed values likeleft 10%now
- updated tokenizer macro
- FEATURE: New preference option
keepUnkownAtRules = Falsewhich defines if unknown atrules like e.g.@three-dee {...}are kept or not. Setting this pref toFalsein result removes unknown @rules from the serialized sheet which is the default for the minified settings. - IMPROVEMENT: Fixed Bitbucket #23. The examples/style.py example renderer was reusing
Propertyobjects for each HTML element so they effectively overwrote each other.
- DOCUMENTATION: Using Sphinx 0.6.1 now
- API CHANGE: Reverted handling of exceptions (Bitbucket #24) as this did not work with PyXML installed. You may again use
- 0.9.6a3 090426
- IMPROVEMENT: Fixed
CSSStyleDeclaration.lengthfor Python 2.6.2 (due to a backport from Python 2.7 to 2.6.2 the reversed() iterator has no __length__ anymore which cssutils was using)
- BUGFIX: New version of encutils (0.9) with these fixes:
- invalid HTML (like
< />) does not stop the encoding detection anymore - fixed
tryEncodingsif chardet is not installed - mismatch is
Falsenow if mime-type istext/xml(or similar) and XML encoding pseudo attribute defines encoding as this is ignored completely! - default encoding for CSS is UTF-8 now if not other HTTP info is given. @charset encoding information is not used by encutils!
- log output for mismatch uses
!=instead of<>now - fixed testcases which were not all tested :(most embarrassing)
- invalid HTML (like
- BUGFIX: Fixed Bitbucket #21 http://code.google.com/p/cssutils/issues/detail?id=21. Definition of valid values for property background-position was wrong. Still mixed values like
background-position: 0 topare invalid although most browsers accept them. But the CSS 2.1 spec defines it the above way. CSS3 backgrounds is not implemented yet in cssutils.
- IMPROVEMENT: Fixed
- 0.9.6a2 090308
API CHANGE: :class:`cssutils.profiles.Profiles` (introduced in 0.9.6a1) has been refactored:
cssutils.profile(acssutils.profiles.Profilesobject) is now preset and available used for all validation- moved variable
cssutils.profiles.defaultprofileto attributeProfiles.defaultProfiles(and so also available ascssutils.profile.defaultProfiles) - renamed
Profiles.CSS_BOX_LEVEL_3toProfiles.CSS3_BOXandProfiles.CSS_COLOR_LEVEL_3toProfiles.CSS3_COLOR - renamed
Profiles.basicmacrostoProfiles._TOKEN_MACROSandProfiles.generalmacrostoProfiles._MACROS. As these two are always added to your property definitions there is no need to use these predefined macro dictionaries in your code. - renamed
Profiles.knownnamestoProfiles.knownNames Profiles.validateWithProfilereturnsvalid, matching, profilesnow- renamed named parameter in
cssutils.css.Property.validate(profiles=None)fromprofiletoprofiles cssutils.profiles.properties(and newcssutils.profiles.macros) use as keys the predefined constants in Profiles, like e.g.Profiles.CSS_LEVEL_2now. If you want to use some of the predefind macros you may e.g. usecssutils.profiles.macros[Profiles.CSS_LEVEL_2]['family-name'](in addition to the always availableProfiles._TOKEN_MACROSandProfiles._MACROS).
CHANGE: Reporting levels of properties have changed. Please see :meth:`cssutils.css.Property.validate` for details. E.g. valid properties in the current profile are only reported on DEBUG and not INFO level anymore. The log output has been changed too, context information is provided now (line, column and name of the relevant property)
- FEATURE: Added new properties as profile
Profiles.CSS3_PAGED_MEDIA: fit, fit-position, image-orientation, page, size and relevant properties already defined inProfiles.CSS_LEVEL_2
- BUGFIX:
p.valid == Falseis now set for Properties not valid in the current profile even if they are valid in a different profile - BUGFIX: Macros used when adding a new profile to
cssutils.profilewere polluted with ALL macros ever defined. They now correctly use the (always used) predefined macrosProfiles._TOKEN_MACROSandPROFILES._MACROSin addition to the given macros (cssutils.profile.addProfile(self, profile, properties, macros=None)) only. If you want to use any macros defined in other profiles you need to add these to your own macros as seen inmacros[Profiles.CSS3_BOX]. - BUGFIX: If
cssutils.ser.prefs.validOnly == Trueserializer incorrectly put a single;for invalid properties out until now.
- IMPROVEMENT: comments added by
cssutils.resolveImportsonly use the @import rules' href and not the absolute href of the referenced sheets anymore (might have been a possible security hole when showing a full local path to a sheet in a combined but not minified sheet) - IMPROVEMENT: IE specific alpha values like
filter: alpha(opacity=80)are parsed and kept now.
- 0.9.6a1 090207
API CHANGE: Known but invalid properties raise/log an ERROR instead of a WARNING now. Properties not expected in the current profile log an INFO. As the default profile is
Noneeven basic properties likecolorare logged now. You may want to change the default profile by setting e.g.cssutils.profiles.defaultprofile = cssutils.profiles.Profiles.CSS_LEVEL_2(~ CSS 2.1) to prevent CSS 2.1 properties to be reported. Also other validation related output has been slightly changed.The way to change a defaultprofile may change again.
API CHANGE:
cssutils.script.csscombinehas ONLY keyword parameters now. Usecsscombine(path=path[,...])for the old behaviour. New parameterurlcombines the sheet at URL now.
FEATURE: Added experimental profiles handling. You may add new profiles with new properties and their validation and set a defaultprofile used for validation. The current default profile is
Noneso all predefined profiles are used. Currently 3 profiles are defined:~cssutils.profiles.Profiles.Profiles.CSS_LEVEL_2Properties defined by CSS2.1
~cssutils.profiles.Profiles.Profiles.CSS_COLOR_LEVEL_3CSS 3 color properties
~cssutils.profiles.Profiles.Profiles.CSS_BOX_LEVEL_3Currently overflow related properties only
See the docs and source of the cssutils.profiles module for details.
FEATURE:
cssutils.util._readUrl()allows fetchers to pre-decode CSS content and return unicode instances, with or without a specified source encoding (integrated from patch of Issue Bitbucket #19).FEATURE: URL fetch method checks if cssutils is run in GoogleAppEngine (GAE) (if
import google.appengineis successful) and uses the GAE fetch methods instead of urllib2 in that case. So in result cssutils should run on GAE just as elsewhere.FEATURE: Function
cssutils.resolveImports(sheet)returns a new stylesheet with all rules in given sheet but with all @import rules being pulled into the top sheet.FEATURE: CSSCombine script and helper function resolve nested imports now.
FEATURE: Script
csscombinehas new option-u URL, --url=URL URL to parse (path is ignored if URL given)now- BUGFIX: Other priority values than
!importantare parsed now. Nevertheless they log an ERROR or raise a SyntaxErr. TODO: Preference setting. Profile?
- BUGFIX: Other priority values than
- IMPROVEMENT: Added all known properties (by cssutils ;) to CSS2Properties.
- DOCUMENTATION: Changed documentation generation from Epydoc and home grown HTML generation to Sphinx. Not all is perfectly markup'd yet but not too bad either...
- 0.9.6a0 081214
FEATURE:
xml.dom.DOMExceptions raised do now contain infos about the position where the exception occured. An exception might for example have been raised as:raise xml.dom.SyntaxErr('the message', 10, 5)(where 10 is the line and 5 the column of the offending text).
Therefor you may not simply use
str(e)to get the exception message but you have to usemsg, line, col = e.args[0], e.args[1], e.args[2]. Additionally exceptions raised have attributese.lineande.col.FEATURE: @page rule accepts named page selector now, e.g.
@page introorpage main:left.FEATURE: Script
cssparsehas new option-u URLwhich parses the given URL.- FEATURE: Started implementation of CSS profiles...
- moved
cssutils.css.cssproperties.cssvaluestocssutils.profiles.css2 - added CSS Color Module Level 3 with properties
colorandopacity. Not implemented are SVG color names. - unknown properties raise a WARNING instead of INFO now
- refactored CSSValue and subclasses therefore there may be some minor changes in serializing or value reporting
getStringValue()returns a string without quotes or for URIs a value without surroundingurl(...)now
- moved
FEATURE experimental: Added class
CSSColorwhich is used for RGB, RGBA, HSL, HSLA and HEX color values ofCSSValuerespectiveCSSPrimitiveValue.FEATURE (strange): IE only CSS expressions should be parsed and serialized now an an
Expressionvalue. I have not tested this deeply and there may be problems but for some common cases this should work, e.g. for hacking maxwidth for IE you may define the following:width: expression(document.body.clientWidth > 1000 ? "1000px": "100%")
Usage of CSS expressions is strongly discouraged as they do not validate AND may slow down the rendering and browser quite a lot!
- BUGFIX/IMPROVEMENT: rewrite of CSSValue and related classes
- BUGFIX: Parsing of a CSSValue like
red /**/(value, Space, comment) fixed. - BUGFIX: Parsing values with
+operator fixed. - BUGFIX:
CSSValueList.__str__added (missing last underscore rendered it useless) - IMPROVEMENT: Serializing e.g.
rgb(0,0,0)now defaults torgb(0, 0, 0) - IMPROVEMENT: HEX values are minified if possible, e.g.
Bitbucket #112233results inBitbucket #123 - IMPROVEMENT: Improved handling of zero lengths like
-0, 0.0, .0mmetc all should come out simply as0now - IMPROVEMENT: number values are normalized now, e.g.
010.0pxresults in10pxetc - IMPROVEMENT: DIMENSIONs are normalized now, e.g.
1pXresults in1px - IMPROVEMENT: for CSSValueList values like e.g.
margin: 0 1pxthere are no more false WARNINGs emitted - IMPROVEMENT: Comments should be parsed much better now
- IMPROVEMENT:
CSSValue.getFloattype(unitType=None), parameter is now optional in which case the current dimension is used. - fixed lots of other minor bugs related to CSSValue
- BUGFIX: Parsing of a CSSValue like
- BUGFIX: Fixed tokenizing/parsing of rather strange STRING and URI values like:
Valid:
"somestring followed by escaped NL\ and continuing here."
and now results in:
"somestring followed by escaped NL and continuing here."
url())=> not allowed and must be written asurl(")")
BUGFIX: Setting
CSSPageRule.selectorTextdoes actually work now.BUGFIX: Other priority values than
!importantare parsed now. Nevertheless they log an ERROR or raise a SyntaxErr.BUGFIX: Fixed Issue Bitbucket #14, added
CSSStyleDeclaration().borderLeftWidth. But prefer to useCSSStyleDeclaration()['border-left.width'].
- API CLEANUP:
- moved validating of a property from
CSSValuetoProperty - removed
CSSValue.validas it does not make sense anymore - removed private init parameter
CSSValue_propertyName - private attribute
CSSValue._valuecontains(value, type)now. Do not use as it may change again - removed
Property.normalname(DEPRECATED from 0.9.5 ), useProperty.nameinstead - removed long deprecated
CSSStyleSheet.replaceUrls, usecssutils.replaceUrls()instead cssutils.utils.Baseandcssutils.utils.Base2have been changed and will be removed in favor of newcssutils.utils._NewBase. These are all internal helper classes and should not be used in client code anyway but ye be warned...
- moved validating of a property from
- IMPROVEMENT:
- minor changes due to deprecation in Py3k. cssutils is NOT Py3k compliant yet though and it will probably take a while until it will be...
- 0.9.5.1 080811
- BUGFIX: Fixed parsing of
}a,bwhich resulted in TypeError until now. - BUGFIX: A rule with a selector using an undefined and therefor invalid namespace prefix is ignored now.
- BUGFIX: Removed typo in MediaList which resulted in Exception when parsing medialist containing
alland another media. - BUGFIX: Reading imported styles may have failed under certain conditions with an AttributeError.
- FEATURE: Added
cssutils.VERSIONwhich is the current release version, in this case e.g."0.9.5.1" - IMPROVEMENT: Optimized imports and partly removed circular ones which are a bit tricky...
- BUGFIX: Fixed parsing of
- 0.9.5 080730
- API CHANGE: If a new medium is trying to be appended to a
MediaListalready set toallanxml.dom.InvalidModificationErris raised. The exception to this handling is addinghandheldwhich is a special case for Opera and kept for now. This special handling may be removed in the future. AWARNINGis logged in any case.
- BUGFIX: Fixed reference error in @import rule preventing change of the used
MediaList. - BUGFIX: Deeply nested
CSSImportRules with different encodings should keep the encoding as defined (via HTTP, parendSheet, @charset etc) now. Thereforcssutils.util._readUrldoes return(encoding, enctype, decodedCssText)now whereenctypeis a number from 0 to 5 indicating which encoding type was used: 0 for encoding override, 1 for HTTP encoding, 2 for BOM or @charset rule, (3 is unused currently), 4 for encoding of the parent sheet and 5 if encoding defaults to UTF-8 as no other information is available. (This may later be done as constants but this function should not be used from programs generally). - BUGFIX: Replaced usage of
WindowsErrorwithOSError. I (naively ;) thoughtWindowsErrorat least be present in environments other than Windows but it just results in aNameError... The part of the API which triggered this Exception is an @import rule with an invalid or local (file) URI so should have happened quite rarely anyway.
- IMPROVEMENT: Standalone scripts
csscombineandcsscaptureare available for programmatic use incssutils.script.csscombineandcssutils.script.CSSCaptureres. - IMPROVEMENT:
cssutils.script.csscombineandcsscombinescript do use the cssutils log now instead of just writing messages tosys.stderr - IMPROVEMENT: Optimized and refactored tokenizer (CHARSET_SYM).
- API CHANGE: If a new medium is trying to be appended to a
- 0.9.5rc2 080714
API CHANGE/BUGFIX (major):
Upto 0.9.5rc1 any sheet resulting from parsing via any
parse*function orCSSParser(raiseExceptions=False)(which also was and is the default) resulted in the library simply logging any later exceptions and not raising them. Until now the global setting ofcssutils.log.raiseExceptions=True(the default) was overwritten with the value of the CSSParserraiseExceptionssetting which normally isFalseany time acssutils.parse*function orCSSParser.parse*method was used. 0.9.5rc2 fixes this.until 0.9.5rc1:
>>> # parsing does not raise errors >>> s = cssutils.parseString('$') # empty but CSSStyleSheet object >>> # using DOM methods does **not raise either** but should: >>> s.cssText = '$' # just logs: ERROR CSSStyleRule: No start { of style declaration found: u'$' [1:2: ]from 0.9.5rc2:
>>> # parsing STILL does not raise errors >>> s = cssutils.parseString('$') # empty but CSSStyleSheet object >>> # using DOM methods **does raise now though** >>> s.cssText = '$' # raises: xml.dom.SyntaxErr: CSSStyleRule: No start { of style declaration found: u'$' [1:1: $]To use the old but false behaviour add the following line at the start to your program:
>>> cssutils.log.raiseExceptions = False # normally True
This should only be done in specific cases as normal raising of exceptions in methods or functions with the CSS DOM is the expected behaviour. This setting may also be removed in the future so use with care.
BUGFIX: Parsing of @rules like
@mediaall ...does not result in@media all ...anymore (so not aCSSMediaRule) but parses as@mediaallso aCSSUnknownRule. The specification is not too clear here but it seems this is the way to go. To help finding typos like this probably is, for any found CSSUnknownRule (an unknown @rule) a WARNING is emitted now (but never an exception raised). These typos will most likely happen like e.g.@mediaall,@importurl(),@namespaceprefix"uri"or@pagename:left.BUGFIX: Parsing of unicode escapes like
\\abcfollowed by CR/LF this is now correctly combined as only a single whitespace character.BUGFIX: Adding a malformed
stylesheets.MediaQueryto astylesheets.MediaListdoes fail now, e.g.:>>> # invalid malformed medialist (missing comma): >>> sheet = cssutils.parseString('@media tv INVALID {a {top: 0;}}') ERROR MediaQuery: Unexpected syntax. [1:11: INVALID] ERROR MediaList: Invalid MediaQuery: tv INVALID >>> # the actual rule exists but has default empty content, this may be changed later as it can be seen as a bug itself >>> sheet.cssRules[0] cssutils.css.CSSMediaRule(mediaText=u'all') >>> sheet.cssText '' >>> # BUT: Unknown media type but as it is valid does parse: >>> sheet = cssutils.parseString('@media tv, UNKNOWN {a {top: 0;}}') WARNING MediaQuery: Unknown media type "UNKNOWN". >>> sheet.cssRules[0] cssutils.css.CSSMediaRule(mediaText=u'tv, UNKNOWN') >>> sheet.cssText '@media tv, UNKNOWN {\n a {\n top: 0\n }\n }'BUGFIX: References to
MediaListinCSSImportRuleandCSSMediaRuleare kept now properly.BUGFIX: Deleting a
MediaQueryitem from aMediaListdoes use the libs logging/raising settings instead of always raisingIMPROVEMENT: Parsing performance has been improved (by about 25%, tested with a basic CSS of about 50 lines, so may not be representative but this release definitely is faster ;). The following changes have been done which should not impact any actual stylesheet:
- A
BOMtoken is recognized at the start of a stylesheet only (may be swallowed by the CSS codec anyway). - A
BOMtoken is not counted in the line/col reporting anymore so the following token has a line and col of 1 now - Tests for tokenizing with css2productions has been removed but this is never used in the library anyway
- A
- 0.9.5rc1 080709
API CHANGE/FEATURE:
The cssutils.logmay 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.setloglevelhas been DEPRECATED and should be used viacssutils.log.setLevel. The old method is still available though.cssutils.log.setloghas been renamed tocssutils.log.setLogbut is still available but DEPRECATED too.FEATURE: All three decoders in the codec now have an additional
forceargument. Ifforceis false, the encoding from the input will only by used if is is detected explicitely via BOM or @charset rule.FEATURE:
cssparsescript has new option-m --minifywhich results in the parsed CSS to be serialized minifiedFEATURE:
CSSCaptureandcsscombineare now available not only as standalone scripts but also viacssutils.script.CSSCaptureandcssutils.script.csscombinerepectively 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 but probably is not valid at all. Other @rules behave similar now too.BUGFIX: Properties of rules set via
css.CSSStyleSheet.addor.insertwere not set properly, e.g.parentStyleSheetor 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 usingparseFile.IMPROVEMENT/BUGFIX: A style sheet with
href == None(e.g. parsed withparseString()or build completely from scratch) usesos.getcwd()as its base href now to be able to resolve CSSImportRules.IMPROVEMENT/BUGFIX: Rewrote
csscombinescript 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.IMPROVEMENT/BUGFIX: Added catching of WindowsError to default fetcher (e.g. is a file URL references a file not present).
CHANGE/BUGFIX: Redone
csscapturescript. A few minor method changes (parameteruaofcapturehas 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. Thecsscombinescript 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, useparseFile()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
encodingforparseString,parseFileandparseUrlfunctions/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 givenencodingis 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@importrule is found and the referenced stylesheet is about to be retrieved.The function gets a single parameter
urlthe URL to read
and MUST return
(encoding, content)whereencodingnormally is the HTTP charset given via a Content-Type header (which may simply omit the charset though) andcontentbeing the (byte) string content. The Mimetype of the fetchedurlshould betext/cssbut 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 --stringto cssparse script which expects a CSS string to be parsed.FEATURE/BUGFIX: Parsing of CSSStyleDeclarations is improved. Invalid
/color: red;color: greenis now correctly parsed ascolor: greennow. 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:
parseUrldoes returnNoneif 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.parseURLhas been renamed toparseUrlfor consistency withgetUrlsorreplaceUrls. Parameterhref(before calledurl) 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
atkeywordof @rules checks if it is a valid keyword for the specific rule. E.g. an @import rule accepts@im\portbut not@namespace. - BUGFIX: Fixed setting
nameof CSSImportRule. Settingnameother than with a string results in xml.dom.SyntaxErr raised now - BUGFIX:
CSSStyleSheet.typewith 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__forcssutils.util._SimpleNamespaceswhich is used in a selector repr.
- API CHANGE:
- 0.9.5b1 080319
API CHANGE:
cssutils.css.CSSSStyleSheet.replaceUrls(replacer)has been DEPRECATED but is available as an utility function so simply usecssutils.replaceUrls(sheet, replacer)instead. For the why seegetUrls(sheet)below.API CHANGE/FEATURE:
parseStringhas a new parameterencodingnow which is used if astris given for cssText. Otherwise it is ignored. (patch by doerwalter)API CHANGE/FEATURE:
.parse() .parseString()and constructor ofCSSStyleSheethave a new parametertitleneeded for the cascade (yet to be implemented ;).Also the representation of
CSSStyleSheethas been improved.
- FEATURE: Referenced stylesheet in an @import rule is read and parsed now if possible. Therefor the
hrefgiven during parsing (parameterhrefto theparse*functions is used. It is also properly set on imported rules. Thenameproperty of the @import rule is set as the imported sheetstitleproperty. - FEATURE: Added
cssutils.getUrls(sheet)utility method to get allurl(urlstring)values inCSSImportRulesandCSSStyleDeclarationobjects (properties). As this function and the above mentionedreplaceUrls(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 Bitbucket #10, using full
$LastChangedDate$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$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
CSSCharsetRulewhere no comments are allowed at all.
- TESTS: Tests need ``minimock`` now! Install with
easy_install minimock
- DOCUMENTATION: Improved docs a bit.
- LICENSE: The included encutils has been updated to version 0.8.2 with a compatible LGPL license. restserver.py 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:
.wellformedreplaces.validfor most classes. This is more an internal value so should be used carefully anyway. Some classes still have both, notablyPropertyandCSSValue. Also removedPreferences.removeInvalidwhich was deprecated for some time now and made not really sense anyway. - API CHANGE: Removed
cssutils.ser.prefs.wellformedOnlywhich 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 ifcss.CSSImportRule.cssTextis 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.nameandcss.CSSMediaRule.nameas decribed in http://www.w3.org/TR/css3-cascade/#cascading. It is parsed, serialized and available in this new property now. Propertynameis a constructor parameter now too.FEATURE:
css.UnknownRuleis 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 exceptatkeyword,cssTextandseqare 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 byCSSImportRuleorCSSNamespaceRuleamong others. All STRING values are serialized with"..."(double quotes) now. This should not be a problem but please note that e.g. aCSSValuemay 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
aall "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:
CSSNamespaceRuleimplements 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
wellformedproperty and serializing included comments better. - IMPROVEMENT: Added simple testtool for functional tests in /examples plus lots of smaller bugfixes, improvements and refactorings
- API CHANGE:
- 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
Selectoretc. This probably is not fixed for all cases but much better now than before.- added
CSSStyleSheet.namespaceswhich is a mapping ofprefix: namespaceURIand mirrors all namespaces as defined in @namespace rules. New Namespaces may also be set here as well as prefixes changed. - if more than one
CSSNamespaceRulewith the samenamespaceURIis set only the last one will be kept. Theprefixof that rule is used. CSSNamespaceRule.namespaceURIis 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(orcssTextfor CSSStyleRule) a tuple of(string-to-parse, dict-of-namespaces)now while not attached to a style sheet. If attacheddict-of-namespacesis 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
- added
- API CHANGE:
parentRuleandparentStyleSheetof 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:
CSSStyleSheetandCSSMediaRuleare iterable now. Both iterate on theircssRules. (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=Falseto methodCSSStyleSheet.insertRulewhich inserts a given rule to its proper hierarchy. Parameterindexis 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.parentListwhich contains a reference to the containingSelectorList. Needed (at least) to process namespaces properly.
BUGFIX:
CSSMediaRule.insertRulesetting with a rule string fixedBUGFIX:
*.parentStyleSheetand*.parentRulewhere * is any CSSRule is properly set nowBUGFIX:
CSSStyleDeclatation.getPropertyPriority(p)returnsimportant(without the"!"!) or the empty string now (see http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration). Same goes forProperty.prioritywhich is not in CSSOM but cssutils only.(
Property._normalpriorityhas been removed, the normalized value that was available here is now inProperty.priority. The literal priority value is available inProperty.literalpropertynow (analog toProperty.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
Selectoraccording to http://dev.w3.org/csswg/cssom/#selectors, e.g.a>b+c~d eserializes asa > b + c ~ d enow (single spaces around +, > and ~). A new serializer preferenceselectorCombinatorSpacer = u' 'has been added to overwrite this behaviour (which is set tou''when using the CSS minifier settings)BUGFIX: Some minor fixes including some reference improvements
- IMPROVEMENT: csscombine is available via
from cssutils.scripts import csscombinenow (not directly in cssutils though!). Some optimizations and comments added.
- 0.9.5a2 080115
- BUGFIX: Serializing a
CSSStyleDeclarationdid not include the effective properties but the last property if set multiple times in a single declaration and preferenceskeepAllProperties == False. - BUGFIX: Fixed parsing of last remaining example in CSS spec
color:red; color{;color:maroon}; color:greenwhich now correctly parsescolor: 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
- BUGFIX: Serializing a
- 0.9.5a1 080113
API CHANGE:
Property.nameis now the same asProperty.normalnamewhich is DEPRECATED now. To access the literal name (the value which was available innameuntil now) useProperty.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.CSSStyleDeclarationyields now effective properties only and not all properties set in the declaration. E.g. fromcolor: red; c\olor: greenonly one Property is returned which has the valuegreen. To retrieve all properties useCSSStyleDeclaration.getProperties(all=True). Reason for this change is that for most cases the new default makes more sense.
FEATURE:
css.CSSStyleDelcarationsupportsinnow. Expected is a Property or a name of a property which is checked if already in the style declarationFEATURE:
css.Selectorhas a readonly propertyspecificitynow which is calculated as described at http://www.w3.org/TR/css3-selectors/#specificityATTENTION: changing the Selector by changing its property
seqdoes not update the specificity!Selector.seq.appendhas been made private therefor and writing toseqnot be used at all!FEATURE: Added
css.CSSStyleDeclaration.getProperty(name, normalize=True)which returns the effective Property object forname.FEATURE: Implemented http://csswg.inkedblade.net/spec/css2.1#issue-23, URI may be
URL(...)oru\r\6c(...)now
- BUGFIX:
CSSStyleDeclaration.removeProperty(name, normalize=True)removes all properties with givennamenow and returns the effective value. Ifnormalize==Falseremoves only properties withname=Property.literalnameand also only returns the effective value of the unnormalized name. - BUGFIX: Priority of Properties is acknowledged by all methods of
css.CSSStylesDeclarationnow. - BUGFIX: Fixed serializing of strings like "\a", "\22" and '\27' in @import urls, selectors and values. func("string") is not yet fixed!!!
- CHANGE:
CSSValueListdoes not emit warnings for shorthand properties anymore. Nevertheless these may be invalid! - IMPROVEMENT:
CSSStyleDeclarationand some minor other parts refactored
- 0.9.4b1 071229
- FEATURE: Added
csscombinescript 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 acss.CSSRuleListin addition to acss.CSSRuleobject 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/**/bMeant 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 bso as if a space would be present. cssutils now parses this selector as intented by the spec asab.a*bAgain spaces around the UNIVERSAL
*were probably meant by the author. IE and Safari seem to parse this invalid selector asa b. cssutils ignores this rule completely!
BUGFIX:
css.CSSRuleListis still a Python list but setting methods like__init__,append,extendor__setslice__are added later on instances of this class if so desired. E.g. CSSStyleSheet addsappendwhich 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
strandreprto cssutils.serializer.Preferences - IMPROVEMENT: Added position information to some error reportings (Property, CSSMediaRule
- FEATURE: Added
- 0.9.4a4 071202
FEATURE: Implemented
css.CSSFontFaceRule.FEATURE: Added
css.CSSStyleSheet.encodingwhich reflects the encoding of an explicit @charset rule. Setting the property toNoneremoves an @charset rule if present and sets the encoding to the default value 'utf-8'. Setting a value ofutf-8sets the encoding to the default value too but the @charset rule is explicitly added.Effectively this removes the need to use
css.CSSCharsetRuledirectly as using this new property is easier and simpler.(A suggestion in the CSSOM but not yet resolved. IMHO it does make sense so it is present in cssutils.
css.CSSCharsetRuleremains though if you really want to use it).
BUGFIX/IMPROVEMENT:
css.SelectorListandstylesheets.MediaListhave (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=> boollen(x)=> integer- get,
deland setx[i] for item in xx.append(item)
The DOM additional methods and properties like
lengthoritem()are still present (and also will be in the future) but the standard Python idioms are probably easier to use.stylesheets.StyleSheetListandcss.CSSRuleListare 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:
!importantis 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, --minifiedto CSSCapture which saves the retrieved CSS files with the cssutils serializer settingPreferences.useMinified().
- BUGFIX: option '-p' of csscapture is removed as it was not used anyway. A new option
-r, --saverawhas been added which defaults toFalse. If given saves raw css otherwise cssutils' parsed files. - BUGFIX: CSSCapture now uses the
cssutils.parseStringmethod so invalid sheets should be saved too. Until now in case of an error the sheet was not saved at all.
- FEATURE: Added option
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\olorbut also unicode escapes like\43olorshould result in the property namecolornowBUGFIX: Selector did fail to parse negation
:not(correctlyBUGFIX: CSSValueList treated a value like
-1pxas 2 entries, now they are correctly 1.BUGFIX: Validation of values for
background-positionwas wrong.BUGFIX:
CSSPrimitiveValue.primitiveValuewas 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
\nis now used instead ofos.linesep.
CHANGE: Invalid Properties like
$topwhich 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. AddedPreferences.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
fontvalue which uses "font-size/line-height" syntax.
- CHANGE:
Preferences.keepAllPropertiesdefaults toTruenow (hardly used but safer if different values have been set which are used by different UAs for example.)
- FEATURE: added
- 0.9.4a1 071021 (new parser [again])
FEATURE: Added a new module
cssutils.codecthat 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.MediaQuerywhich 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 callingDOMImplementationCSS.createCSSStyleSheet(title, media). For most cases it is probably easier to make a new StyleSheet by getting an instance ofcssutils.css.CSSStyleSheetthough.FEATURE: cssutils is registered to
xml.dom.DOMImplementationclaiming 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.uriis renamed toCSSNamespaceRule.namespaceURIwhich is defined is CSSOM.uriis deprecated and still available but the constructor parameter is namednamespaceURIin any case now. - API CHANGE: As
stylesheets.MediaQueryis implemented now all classes using an instance ofstylesheets.MediaListare presented slightly different. Until now a simple list of string was given, now the list contains MediaQuery objects. - API CHANGE:
_Propertyhas been renamed tocss.Propertyand is used in context ofCSSStyleDeclarationandMediaQuery. AttributeProperty.valuehas been de-deprecated and may be used normally now (again). The Property constructor has only optional parameters now. - API CHANGE: Removed experimental class
SameNamePropertyListwhich was used inCSSStyleDeclarationand also methodCSSStyleDeclaration.getSameNamePropertyList. A new methodCSSStyleDeclaration.getProperties()has been added which is simpler and more useful - API CHANGE: renamed attribute
namespacesof CSSStyleSheet and Selector toprefixesas they really are the prefixes of declared namespaces
- API CHANGE (internal): renamed
Serializer.do_css_PropertytoSerializer.do_Propertyas it isPropertyis not in the official DOM, may not stay in packagecssand is used by MediaQuery too - API CHANGE (internal): renamed
Serializer.do_CSSvaluetoSerializer.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
cssValueTypeStringwhich is the name of the relevantcssValueType, e.g. "CSS_PRIMITIVE_TYPE". Mainly useful for debugging. - FEATURE: CSSPrimitiveValue has property
primitiveTypeStringwhich is the name of the relevantprimitiveType, e.g. "CSS_PX". Mainly useful for debugging. - CSSValue has an init Parameter
_propertynameto 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,cssValueandpriority. 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 !importantATTENTION: 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 givenseparatorwhich 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:
hrefandmediaarguments can now be passed toparse()andparseString()functions and methods. This sets the appropriate attributes on the generated stylesheet objects.FEATURE: CSSMediaRule has an init parameter
mediaTextsynchronous to CSSImportRule nowFEATURE: The
MediaListconstructor can now be passed a list of media types.FEATURE:
CSSRuleand subclasses have a propertytypeStringwhich is the name of the relevanttype, e.g.STYLE_RULE. Mainly useful for debugging.FEATURE:
cssutils.serialize.Preferenceshas a new optionlineSeparatorthat is used as linefeed character(s). May also be set tou''forCSSStyleDeclareation.cssText'to be directly usable in e.g. HTML style attributes
- API CHANGE (internal): renamed serializers method
do_stylesheettodo_CSSStyleSheet
- BUGFIX (Bitbucket #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.
backgroundshould return None. cssutils returns a CSSValueList in these cases now. Use with care as this may change laterCHANGE: CSSValue default cssText is now
u""and notu"inherit"anymoreCHANGE:
css.CSSStyleDeclaration.cssTextindents its property not anymore.CHANGE:
cssutils.serialize.CSSSerializerhas 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
cssparsehandles more than one file at a time now (patch from Issue Bitbucket #6 by Walter Doerwald) - BUGFIX: Fixed Issue Bitbucket #7: typo gave AssertionError for selectors like
tr:nth-child(odd) td{} - BUGFIX: Fixed Issue Bitbucket #5: false warning for certain values for
background-positionremoved - 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 Bitbucket #3 and Bitbucket #4 to tokenizer too
- FEATURE: Script
- 0.9.2b2 070728
- BUGFIX: Fixed Issue Bitbucket #4, tokenizing of color values like
Bitbucket #00awas buggy (mixture of numbers and characters). Also warnings of invalid property values should be more reliable now (regexes incss.csspropertieschanged).
- BUGFIX: Fixed Issue Bitbucket #4, tokenizing of color values like
- 0.9.2b1 070726
- BUGFIX: Fixed Issue Bitbucket #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
getFormattedand`pprintfrom 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.tokensuptowhich 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.omitLastSemicolonoption. IfTrueomits ; after last property of CSSStyleDeclaration - BUGFIX: The css validator definition for "num" was wrong, so values like
-5.5emwould 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.Selectorhad 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 normalEach property can be retrieved from CSSStyleDeclaration object with its name as an object property. Names with "-" in it like
font-styleneed to be called by the respective DOM namefontStyle. Setting a property value works the same way and evendelwhich 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 +
defaultAtKeywordinstead ofnormalkeyword+defaultPropertyNameinstead ofnormalpropertynamecamelcase now: +
keepCommentsinstead ofkeepComments+lineNumbersinstead oflinenumbersreplaced (see below) +
keepAllPropertiesinstead ofkeepsimilarnamedproperties- FEATURE:
Serializer.prefs.keepAllPropertiesreplaces ``keepsimilarnamedproperties: if
Trueall 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:
- FEATURE(experimental, might change!):
CSSStyleDeclaration.getSameNamePropertyList(name)Experimental method to retrieve a SameNamePropertyList object which holds all Properties with the givenname. The object has an attributenameand a list of Property objects each with an actual name, value and priority.UPDATE: SameNamePropertyList removed in 0.9.4
CSSStyleDeclaration.setPropertyhas a new positional parameteroverwritewhich defines if the property which is set overwrites any former value (or values, seegetSameNamePropertyList) (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
namefor CSSStyleDeclaration.XXX(name)` is normalized now, socolor,c\olorandCOLORare all equivalent
- 0.9.1b2 070111
- FEATURE: added
Serializer.prefs.keepsimilarnamedproperties: if
Trueall properties with the same normalname but different actual names are kept, e.g. color, color, color. This is mainly useful to keep a stylesheet complete which uses xbrowser hacks as above.UPDATE IN 0.9.1b3!
- FEATURE: added
BUGFIX (minor):
Serializer.prefs.normalpropertynamedid not work properly if a property was set 2 times in the same declaration, e.g.color: red;c\olor: greensetting the pref toFalseresults inc\olor: greennow.BUGFIX (minor): Serializing of CSSStyleDeclaration did not work well when CSSComments were mixed with Properties.
- 0.9.1b1
- FUTURE CHANGE:
readonlywill 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.addRulewhich 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
validproperty is set toFalseand the serializer omits it (you may changePreferences.removeInvalidto change this behaviour). - CSSStyleSheet and Selector object have a new propery
namespaceswhich currently contain declared and used namespace prefixes (!), this may change in the future so use with care if at all.
- FEATURE: implemented
CSSRule.parentStyleSheetfor all rules - FEATURE: implemented
CSSRule.parentRulefor relevant rules (all allowed in @media) - BUGFIX: Set
parentStyleSheetandparentRuleas instance vars incss.CSSRuleinstead 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 as opposed to the Proposed Recommendation now. As there are no main changes I could find this does not make any difference...
- FUTURE CHANGE:
- 0.9.1a1
CHANGE, renamed
Serializer.prefs.srcatkeywordtoSerializer.prefs.normalkeywordwhich work just the other way round but work asSerializer.prefs.normalpropertynameBUGFIX in css.Selector and added support regarding handling of pseudoclasses (
:xor: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 toTrue.removed
Token.literalwhich value is invaluenow, normalized value is innormalvalueremoved
Token.ESCAPE. Escapes are contained in IDENTifiers now.internal change: WS is generally kept by tokenizer now, former normalized value
u' 'is hold inToken.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 toTrue.
- 0.9a6
- NEW
Serializer.prefs.keepcommentsremoves all comments ifFalse, defaults toTrue - NEW
Serializer.prefs.srcatkeywordUPDATE see 9.91a1 - fixed tokenizer to handle at least simple escapes like
c\olorwhich is the same ascolor. The original value is preserved but not used yet except in CSSComments which preserve the original values. See also Serializer.prefs.srcatkeywords CSSMediaRuletested and lots of bugfixes- constructor has no parameters anymore (
mediaTextis removed!) addRuleis DEPRECATED, useinsertRule(rule)with no index instead. Synchronized withCSSStyleSheet.insertRule
- constructor has no parameters anymore (
- setting of
CSSImportRule.mediaremoved, use methods of this object directly. Synchronized withCSSMediaRule.media CSSStyleSheet.insertRuleraisesxml.dom.IndexSizeErrif an invalid index is given. Index may beNonein 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
- NEW
- 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
atkeywordwhich is the keyword used in the CSS provided. Normally something like "@import" but may also be an escaped version like "@import" 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)
- added CSS3 combinator
- 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 == FalseProperties 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
typewhich is now set as a static type to "text/css" - removed
addRulewhich emits DeprecationWarning now UseinsertRulewithout parameterindex - added new methods
setSerializer(cssserializer)andsetSerializerPref(self, pref, value)to control output of a stylesheet directly.
- removed init parameter
- CSSStyleRule:
- new property
selectorListis an instance of SelectorList which contains a list of all Selector elements of the rule - removed
addSelector()andgetSelectors(), use propertyselectorListinstead - removed
getStyleDeclaration()andsetStyleDeclaration(), use propertystyleinstead
- new property
- CSSStyleDeclaration:
- new constructor parameter
cssText
- new constructor parameter
- moved
SelectorList,SelectorandPropertyto own modules. Should not be used directly yet anyway. - Token: renamed
IMPORTANTtoIMPORTANT_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
- CSSCharsetRule serialized and parsed according to spec only as
- 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
cssparsewhich pprints css "filename"
- new script
- subpackages
cssandstylesheetsare directly available fromcssutilsnow - renamed module
cssutils.cssparsertocssutils.parsewhich should not be used directly anyway. Always usecssutils.CSSParserorcssutils.parse(s.b) - added utility functions
parse(cssText)andparse(filename, encoding='utf-8')to cssutils main package which work like the CSSParser functions with the same name and API - return value of
.cssTextisu''and notNoneif 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.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 -hto view all options
- cssutils.css.CSSStyleSheet defines
literalCssTextproperty if propertycssTextis 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