Crate simplecss

Source
Expand description

A simple CSS 2.1 parser and selector.

This is not a browser-grade CSS parser. If you need one, use cssparser + selectors.

Since it’s very simple we will start with limitations:

Β§Limitations

  • At-rules are not supported. They will be skipped during parsing.
  • Property values are not parsed. In CSS like * { width: 5px } you will get a width property with a 5px value as a string.
  • CDO/CDC comments are not supported.
  • Parser is case sensitive. All keywords must be lowercase.
  • Unicode escape, like \26, is not supported.

Β§Features

  • Selector matching support.
  • The rules are sorted by specificity.
  • !important parsing support.
  • Has a high-level parsers and low-level, zero-allocation tokenizers.
  • No unsafe.

ModulesΒ§

selector πŸ”’
stream πŸ”’

StructsΒ§

Declaration
A declaration.
DeclarationTokenizer
A declaration tokenizer.
Rule
A rule.
Selector
A selector.
SelectorTokenizer
A selector tokenizer.
StyleSheet
A style sheet.
TextPos
A position in text.

EnumsΒ§

AttributeOperator
An attribute selector operator.
Error
A list of possible errors.
PseudoClass
A pseudo-class.
SelectorToken
A selector token.

TraitsΒ§

Element
A trait to query an element node metadata.

FunctionsΒ§

consume_at_rule πŸ”’
consume_block πŸ”’
consume_declaration πŸ”’
consume_declarations πŸ”’
consume_rule_set πŸ”’
consume_statement πŸ”’
consume_term πŸ”’
consume_until_block_end πŸ”’