css-sanitizer
Classes to parse and sanitize CSS
|
Parse CSS into a structure for further processing. More...
Public Member Functions | |
__construct (Tokenizer $tokenizer) | |
getParseErrors () | |
Return all parse errors seen so far. | |
clearParseErrors () | |
Clear parse errors. | |
parseStylesheet () | |
Parse a stylesheet. | |
parseRuleList () | |
Parse a list of rules. | |
parseRule () | |
Parse a rule. | |
parseDeclaration () | |
Parse a declaration. | |
parseDeclarationList () | |
Parse a list of declarations. | |
parseDeclarationOrAtRuleList () | |
Parse a list of declarations and at-rules. | |
parseComponentValue () | |
Parse a (non-whitespace) component value. | |
parseComponentValueList () | |
Parse a list of component values. | |
parseCommaSeparatedComponentValueList () | |
Parse a comma-separated list of component values. | |
Static Public Member Functions | |
static | newFromString ( $source, array $options=[]) |
Create a Parser for a CSS string. | |
static | newFromDataSource (DataSource $source, array $options=[]) |
Create a Parser for a CSS DataSource. | |
static | newFromTokens (array $tokens, ?Token $eof=null) |
Create a Parser for a list of Tokens. | |
Protected Member Functions | |
consumeToken () | |
Consume a token. | |
consumeTokenAndWhitespace () | |
Consume a token, also consuming any following whitespace (and comments) | |
parseError ( $tag, Token $token, array $data=[]) | |
Record a parse error. | |
consumeRuleList ( $topLevel) | |
Consume a list of rules. | |
consumeDeclarationOrAtRuleList ( $allowAtRules=true) | |
Consume a list of declarations and at-rules. | |
consumeDeclaration () | |
Consume a declaration. | |
consumeAtRule () | |
Consume an at-rule. | |
consumeQualifiedRule () | |
Consume a qualified rule. | |
consumeComponentValue () | |
Consume a component value. | |
consumeSimpleBlock () | |
Consume a simple block. | |
consumeFunction () | |
Consume a function. | |
Protected Attributes | |
$tokenizer | |
$currentToken = null | |
$parseErrors = [] | |
$cvDepth = 0 | |
Parse CSS into a structure for further processing.
This implements the CSS Syntax Module Level 3 candidate recommendation.
The usual entry points are:
Wikimedia\CSS\Parser\Parser::__construct | ( | Tokenizer | $tokenizer | ) |
Tokenizer | $tokenizer | CSS Tokenizer |
|
protected |
Consume an at-rule.
|
protected |
Consume a component value.
|
protected |
Consume a declaration.
|
protected |
Consume a list of declarations and at-rules.
bool | $allowAtRules | Whether to allow at-rules. This flag is not in the spec and is used to implement the non-spec self::parseDeclarationList(). |
|
protected |
Consume a function.
|
protected |
Consume a qualified rule.
|
protected |
Consume a list of rules.
bool | $topLevel | Determines the behavior when CDO and CDC tokens are encountered |
|
protected |
Consume a simple block.
Wikimedia\CSS\Parser\Parser::getParseErrors | ( | ) |
Return all parse errors seen so far.
|
static |
Create a Parser for a CSS DataSource.
DataSource | $source | CSS to parse. |
array | $options | Configuration options, see DataSourceTokenizer::__construct(). |
|
static |
Create a Parser for a CSS string.
string | $source | CSS to parse. |
array | $options | Configuration options, see DataSourceTokenizer::__construct(). Also,
|
|
static |
Create a Parser for a list of Tokens.
Token[] | $tokens | Token-stream to parse |
Token | null | $eof | EOF-token |
Wikimedia\CSS\Parser\Parser::parseCommaSeparatedComponentValueList | ( | ) |
Parse a comma-separated list of component values.
Wikimedia\CSS\Parser\Parser::parseComponentValue | ( | ) |
Parse a (non-whitespace) component value.
Wikimedia\CSS\Parser\Parser::parseComponentValueList | ( | ) |
Parse a list of component values.
Wikimedia\CSS\Parser\Parser::parseDeclaration | ( | ) |
Parse a declaration.
Wikimedia\CSS\Parser\Parser::parseDeclarationList | ( | ) |
Parse a list of declarations.
Wikimedia\CSS\Parser\Parser::parseDeclarationOrAtRuleList | ( | ) |
Parse a list of declarations and at-rules.
|
protected |
Record a parse error.
string | $tag | Error tag |
Token | $token | Report the error as starting at this token. |
array | $data | Extra data about the error. |
Wikimedia\CSS\Parser\Parser::parseRule | ( | ) |
Parse a rule.
Wikimedia\CSS\Parser\Parser::parseRuleList | ( | ) |
Parse a list of rules.
Wikimedia\CSS\Parser\Parser::parseStylesheet | ( | ) |
Parse a stylesheet.