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
CssAST is typically generated via thecrate::ast::Tree::flatten_treemethod. - Qual
Nested Ruleset - Qual
Rule - Qual
Ruleset - Rule
- A CSS rule, of the form
xxx: yyy(delimited by;in a ruleset). - Selector
- A set of selector alternatives separated by
,, for examplediv, span. - Selector
Attr - A selector which matches attributes, optionally against their value as well. TODO doesn’t support comma-separated multiple selectors.
- Selector
Ruleset - Selector
Term - A single compound CSS selector, parameterized over it’s
tagfield 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.
Treealso implementsRenderCssif 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{}.Rulesetis generic over the specific type of itsrulesfield, which ultimately determines whether this struct is recursive (in itsTreeRulesetvariant) or not (in itsFlatRulesetvariant). - Selector
Path - 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 aSelectorListis the special selector&, as special casePartialConselimantestagas a field from this first Selector, preventing theSelectorListfrom being serialized before being flattened. - Tree
Rule - A tree node which expresses a recursive
ToverRuleset<T>. Using this struct in place ofRuleallows nested CSS selectors that can be later flattened.
Type Aliases§
- Flat
Ruleset - A flat (non-recursive) block, suitable for compatibility with modern browsers.
- Tree
Ruleset - A nested recursive block, ala popular CSS tools and the CSS nesting proposal.