Skip to main content

Module parser2

Module parser2 

Source
Expand description

CSS string parser (tokenizer, declaration parser, shorthand expansion). High-level types and functions related to CSS parsing.

Main entry point: [new_from_str] parses a CSS string into a [Css] value plus a list of recoverable warnings. Errors are downgraded to warnings so that partially-valid CSS still produces usable output.

Supports @media, @theme, @os, @lang, and @container at-rules, CSS nesting, CSS variables (var(--name, default)), and comma-separated selector lists. Tokenisation is delegated to azul_simplecss.

Most error types come in borrowed/owned pairs (e.g. CssParseError<'a> / CssParseErrorOwned) so they can be returned across the FFI boundary.

Re-exports§

pub use crate::props::property::CssParsingError;

Structs§

CssParseError
Error that can happen during the parsing of a CSS value
CssParseErrorOwned
Owned version of CssParseError, without references.
CssParseWarnMsg
CssParseWarnMsgOwned
Owned version of CssParseWarnMsg, where warning is the owned type.
CssSyntaxErrorPos
FFI-safe position of a CSS syntax error.
CssSyntaxInvalidAdvance
FFI-safe wrapper for invalid advance details in CSS syntax errors.
ErrorLocation
ErrorLocationRange
FFI-safe replacement for (ErrorLocation, ErrorLocation) tuple. Represents a range (start..end) in the source text.
UnknownPropertyKeyError
Wrapper for UnknownPropertyKey error.
UnknownSelectorError
Wrapper for UnknownSelector error.
UnparsedCssRuleBlock
UnparsedCssRuleBlockOwned
Owned version of UnparsedCssRuleBlock, with BTreeMap of Strings.
VarOnShorthandPropertyError
Wrapper for VarOnShorthandProperty error.

Enums§

CssParseErrorInner
CssParseErrorInnerOwned
CssParseWarnMsgInner
CssParseWarnMsgInnerOwned
CssPathParseError
CssPathParseErrorOwned
CssPseudoSelectorParseError
CssPseudoSelectorParseErrorOwned
CssSyntaxError
FFI-safe CSS syntax error type, mirrors azul_simplecss::Error.
DynamicCssParseError
Error that can happen during css_parser::parse_key_value_pair
DynamicCssParseErrorOwned
SimplecssError
List of all supported errors.

Functions§

new_from_str
Parses a CSS string into a Css value and a list of recoverable warnings.
parse_attribute_selector
Parses the inner content of an attribute selector token (the text between [ and ]).
parse_css_declaration
Parses a single CSS key-value declaration, appending results to declarations.
parse_css_path
Parses a CSS path from a string (only the path,.no commas allowed)
pseudo_selector_from_str
“selector” contains the actual selector such as “nth-child” while “value” contains an optional value - for example “nth-child(3)” would be: selector: “nth-child”, value: “3”.