PureHTML. Query. Selector. Tokenizer
(PureHTML v0.4.0)
View Source
Tokenizes CSS selector strings into a stream of tokens.
Token Types
{:ident, value}- Identifier (tag name, attribute name/value){:class, value}- Class selector (.class){:id, value}- ID selector (#id):star- Universal selector (*):open_bracket- Opening bracket for attribute selector:close_bracket- Closing bracket for attribute selector:equal- Exact match (=):prefix_match- Prefix match (^=):suffix_match- Suffix match ($=):substring_match- Substring match (*=):comma- Selector list separator{:string, value}- Quoted string:child- Child combinator (>):adjacent_sibling- Adjacent sibling combinator (+):general_sibling- General sibling combinator (~):whitespace- Whitespace (potential descendant combinator)
Summary
Functions
Tokenizes a CSS selector string into a list of tokens.
Types
Functions
Tokenizes a CSS selector string into a list of tokens.
Examples
iex> PureHTML.Query.Selector.Tokenizer.tokenize("div")
[{:ident, "div"}]
iex> PureHTML.Query.Selector.Tokenizer.tokenize(".class")
[{:class, "class"}]
iex> PureHTML.Query.Selector.Tokenizer.tokenize("#id")
[{:id, "id"}]
iex> PureHTML.Query.Selector.Tokenizer.tokenize("div.foo#bar")
[{:ident, "div"}, {:class, "foo"}, {:id, "bar"}]