API Documentation

class cssdecl.CSS22Resolver(initial=None)[source]

Parses and resolves CSS to atomic CSS 2.2 properties

Methods

resolve_string(declarations_str, inherited=None)

Resolve the given declarations to atomic properties

Parameters:

declarations_str : str

A list of CSS declarations

inherited : dict, optional

Atomic properties indicating the inherited style context in which declarations_str is to be resolved. inherited should already be resolved, i.e. valid output of this method.

Returns:

props : dict

Atomic CSS 2.2 properties mapped to their values as strings

Examples

>>> resolver = CSS22Resolver()
>>> inherited = {'font-family': 'serif', 'font-weight': 'bold'}
>>> out = resolver.resolve_string('''
...               border-color: BLUE RED;
...               font-size: 1em;
...               font-size: 2em;
...               font-weight: normal;
...               font-weight: inherit;
...               ''', inherited)
>>> sorted(out.items())  
[('border-bottom-color', 'blue'),
 ('border-left-color', 'red'),
 ('border-right-color', 'red'),
 ('border-top-color', 'blue'),
 ('font-family', 'serif'),
 ('font-size', '24pt'),
 ('font-weight', 'bold')]
class cssdecl.CSSWarning[source]

Warning for when this CSS syntax cannot currently be parsed

Attributes