Parses a CSS string into {page_rules, style_rules}.
Never fails: a rule with no closing } is dropped, and a declaration
that doesn't parse as a recognized property/value is silently
skipped, same as a browser. See
docs/superpowers/specs/2026-07-24-css-parser-cascade-design.md for
the full design.
Examples
iex> Press.CSS.Parser.parse("h1 { color: red; }")
{[], [%Press.CSS.Rule{selector: [%{type: "h1"}], specificity: {0, 0, 1}, declarations: %{"color" => {1.0, 0.0, 0.0}}, source_index: 0}]}
Summary
Functions
Parses a raw CSS string into a tuple of {page_rules, style_rules}.
Parses a CSS declarations string (e.g. from an inline style="..." attribute)
into a map of property-value pairs.
Functions
@spec parse(String.t()) :: {[Press.CSS.PageRule.t()], [Press.CSS.Rule.t()]}
Parses a raw CSS string into a tuple of {page_rules, style_rules}.
Parses a CSS declarations string (e.g. from an inline style="..." attribute)
into a map of property-value pairs.