Skip to main content

Module selector

Module selector 

Source
Expand description

Minimal CSS-subset selector for streaming-parser emit modes.

§Supported syntax

SyntaxMeaning
tagelement name matches tag
*any element
.classclass attribute contains the token (HTML semantics)
#idid attribute equals
[attr]element has the attribute
[attr=value]attribute equals (unquoted, "…", or '…')
A BB is a descendant of A
A > BB is a direct child of A

Simple selectors combine: tag.class.other#id[attr][a=b]. Combinators chain: feed > entry[type="article"].

§Intentionally unsupported

  • :pseudo-classes like :nth-child — most need lookahead the streaming parser cannot provide.
  • ~ and + sibling combinators — same reason.
  • Attribute operators other than =: no ~=, |=, ^=, $=, *=.
  • Comma-separated multi-selectors (a, b).

§Anchoring

Like real CSS, selectors are not anchored to the document root. item matches an <item> element anywhere, including nested ones. Use a path-based emit mode on the streaming parser when you need exact root-anchored matching with guaranteed memory bounding.

Structs§

ParseSelectorError
Error parsing a selector string.
Selector
A parsed selector. Construct with Selector::parse.