css_select/parser

Types

Error returned when parsing fails.

pub type ParseError {
  ParseError(String)
}

Constructors

  • ParseError(String)

A reusable parser instance with pre-built splitters.

Create with new() and pass to parse_simple_selector_with_parser/2 for best performance when parsing many selectors.

pub opaque type Parser

Values

pub fn new() -> Parser

Create a new parser instance with pre-built splitters.

Use this when parsing multiple selectors to avoid the overhead of creating splitters on each call.

let parser = parser.new()
parser.parse_simple_selector_with_parser(parser, "div#foo")
parser.parse_simple_selector_with_parser(parser, ".bar")
pub fn parse(
  parser: Parser,
  input: String,
) -> Result(selector.Selector, ParseError)

Parse a CSS selector string using a pre-created Parser.

This avoids the overhead of creating splitters on each call. Create a Parser once with new() and reuse it for all parsing.

Search Document