Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.2
Fetching contributors…

Cannot retrieve contributors at this time

98 lines (66 sloc) 2.501 kb

Parsing with tinycss

Quickstart

Import tinycss, make a parser object with the features you want, and parse a stylesheet:

You’ll get a :class:`~tinycss.css21.Stylesheet` object which contains all the parsed content as well as a list of encountered errors.

Parsers

Parsers are subclasses of :class:`tinycss.css21.CSS21Parser`. Various subclasses add support for more syntax. You can choose which features to enable by making a new parser class with multiple inheritance, but there is also a convenience function to do that:

Parsing a stylesheet

Parser classes have three different methods to parse CSS stylesheet, depending on whether you have a file, a byte string, or an Unicode string.

Parsing a style attribute

Parsed objects

These data structures make up the results of the various parsing methods.

Note

All subsequent objects have :obj:`line` and :obj:`column` attributes (not repeated every time fore brevity) that indicate where in the CSS source this object was read.

Tokens

Some parts of a stylesheet (such as selectors in CSS 2.1 or property values) are not parsed by tinycss. They appear as tokens instead.

Jump to Line
Something went wrong with that request. Please try again.