Skip to main content
``cssdecl`` Python CSS declaration computer
-------------------------------------------

|version| |py-versions|

|build| |docs| |coverage|


This package provides basic computation of CSS declarations in order to:

* handle overwriting of properties

>>> from cssdecl import CSS22Resolver
>>> resolve = CSS22Resolver().resolve_string
>>> resolve('font-size: 10pt; font-size: 12pt')
{'font-size': '12pt'}

* expand shorthands like `border-width: 0 5pt`

>>> resolved = resolve('border-width: 0 5pt')
>>> resolved.pop('border-left-width')
'5pt'
>>> resolved.pop('border-right-width')
'5pt'
>>> resolved.pop('border-bottom-width')
'0pt'
>>> resolved.pop('border-top-width')
'0pt'
>>> resolved
{}

* (TODO!) expand shorthands like `font: 5px sans-serif bold` into `font-family: sans-serif`, `font-size: 5px`, `font-weight: bold`
* resolve sizes to a common unit (i.e. pt)

>>> resolve('font-size: 20px')
{'font-size': '15pt'}
>>> resolve('font-size: 1em')
{'font-size': '12pt'}
>>> resolve('font-size: 1em', inherited={'font-size': '20pt'})
{'font-size': '20pt'}
>>> resolve('font-size: small')
{'font-size': '9.600000pt'}

* resolve `inherit` given some inherited declarations

>>> resolve('color: red; color: inherit', inherited={'color': 'blue'})
{'color': 'blue'}

Some properties that are not shorthands in CSS 2.2 become
shorthands in CSS 3, such as `text-decoration`. We therefore
hope to provide :class:`cssdecl.CSS22Resolver` and :class:`cssdecl.CSS3Resolver`.

This module does *not* process CSS selectors (e.g. ``#some-id > * > div.some-class``) and their applicability to elements, including specificity (e.g. ``!important``).

This was first developed for use in Pandas_ (`#15530 <https://github.com/pandas-dev/pandas/pull/15530>`_).
Issues will continue to be prioritised to improve CSS support there, in the absence of other clear use-cases.


.. _Pandas: http://pandas.pydata.org


.. |py-versions| image:: https://img.shields.io/pypi/pyversions/Django.svg
:alt: Python versions supported

.. |version| image:: https://badge.fury.io/py/cssdecl.svg
:alt: Latest version on PyPi
:target: https://badge.fury.io/py/cssdecl

.. |build| image:: https://travis-ci.org/jnothman/cssdecl.svg?branch=master
:alt: Travis CI build status
:scale: 100%
:target: https://travis-ci.org/jnothman/cssdecl

.. |coverage| image:: https://coveralls.io/repos/github/jnothman/cssdecl/badge.svg
:alt: Test coverage
:target: https://coveralls.io/github/jnothman/cssdecl

.. |docs| image:: https://readthedocs.org/projects/cssdecl/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://cssdecl.readthedocs.io/en/latest/?badge=latest

Metadata

Release files for cssdecl 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cssdecl 0.1.2
File Size Uploaded Provenance Actions
cssdecl-0.1.2.tar.gz 4.8 kB Without provenance Details for cssdecl-0.1.2.tar.gz

Release files / cssdecl-0.1.2.tar.gz

Download URL cssdecl-0.1.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
05db0d001fbb822a9ee2e04b32eb4a34481a2568caff424e4092aced1725658c
BLAKE2b-256 checksum
How to use checksums
e5e3a6a8e330e4cd06e7a5d93edb3fc2fffbf2b5a51bbc9c1b5905e35d656df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cssdecl 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page