Skip to main content

Module ast

Module ast 

Source
Expand description

The complete AST structs for Css and Tree. These top-level structs are part of the crate::parse API, and their various components structs are necessary for writing any transformations on these between parsing and rendering.

Structs§

Css
A non-nested “flat” CSS representation, suitable for browser output. The Css AST is typically generated via the crate::ast::Tree::flatten_tree method.
QualNestedRuleset
QualRule
QualRuleset
Rule
A CSS rule, of the form xxx: yyy (delimited by ; in a ruleset).
Selector
A set of selector alternatives separated by ,, for example div, span.
SelectorAttr
A selector which matches attributes, optionally against their value as well. TODO doesn’t support comma-separated multiple selectors.
SelectorRuleset
SelectorTerm
A single compound CSS selector, parameterized over it’s tag field such that the uniqu wildcard and self selectors can re-use the same struct and some tag-irrelevent functions can be shared between impls.
Tree
A nested CSS representation yielded from parsing. Tree also implements RenderCss if this is needed, though this output can’t be read by browsers and is not identical to the input since whitespace has been discarded.

Enums§

Combinator
A selector combinator, used to combine a list of selectors.
Ruleset
A collection of rules (or other T), delimited by {}. Ruleset is generic over the specific type of its rules field, which ultimately determines whether this struct is recursive (in its TreeRuleset variant) or not (in its FlatRuleset variant).
SelectorPath
A linked-list-like data structure representing CSS selector lists, which are selectors separated by combinators like >, + or most commonly just whitespace. When the first selector in a SelectorList is the special selector &, as special case PartialCons elimantes tag as a field from this first Selector, preventing the SelectorList from being serialized before being flattened.
TreeRule
A tree node which expresses a recursive T over Ruleset<T>. Using this struct in place of Rule allows nested CSS selectors that can be later flattened.

Type Aliases§

FlatRuleset
A flat (non-recursive) block, suitable for compatibility with modern browsers.
TreeRuleset
A nested recursive block, ala popular CSS tools and the CSS nesting proposal.