Enum CssTokenKind
The kinds of token the CSS Syntax 3 tokenizer produces.
public enum CssTokenKind
Fields
AtKeyword = 2An at-keyword, such as
@media.BadString = 5A string cut off by a newline.
BadUrl = 7An unquoted
url(...)with characters it may not contain.Cdc = 14-->.Cdo = 13<!--.Colon = 15:.Comma = 17,.Delim = 8Any other single character, such as
*or>.Dimension = 11A number followed by a unit, such as
12px.EndOfFile = 24The end of the input. Tokenize(string, CssParseOptions?) does not return it.
Function = 1A function name with its opening parenthesis, such as
rgb(.Hash = 3A hash, such as
#fffor#main.Ident = 0An identifier, such as
redor--x.LeftCurly = 22{.LeftParenthesis = 20(.LeftSquare = 18[.Number = 9A number.
Percentage = 10A number followed by
%.RightCurly = 23}.RightParenthesis = 21).RightSquare = 19].Semicolon = 16;.[SuppressMessage("Naming", "CA1720", Justification = "The CSS Syntax token's name.")] String = 4A quoted string.
Url = 6An unquoted
url(...).Whitespace = 12One or more whitespace characters.
Examples
// CSS Syntax 3 tokens, and component values: tokens, functions and simple blocks.
IReadOnlyList<CssToken> tokens = CssTokenizer.Tokenize("rgb(255 0 0 / 50%) 12px");
CssToken first = tokens[0];
bool isFunction = first.Kind == CssTokenKind.Function; // "rgb(" at line 1, column 1
IReadOnlyList<CssComponentValue> values = CssComponentValue.ParseList("calc(100% - 2px) [a] x");
var calc = (CssFunction)values[0];
var block = (CssSimpleBlock)values[2];
var word = (CssTokenValue)values[4];
string text = CssComponentValue.Serialize(values); // "calc(100% - 2px) [a] x"