Skip to content

Latest commit

 

History

History
456 lines (364 loc) · 5.21 KB

ast.md

File metadata and controls

456 lines (364 loc) · 5.21 KB

AST format

CSSTree's AST is an object tree. Each node is object with type property that indicates its type. Other property set depends on node type.

Each node have a loc property, but not included in descriptions to avoid noise. Its value contains an object with node content positions in source string or null depending on parsing settings.

Node types:

AnPlusB

{
    "type": "AnPlusB",
    "a": String | null,
    "b": String | null
}

Atrule

{
    "type": "Atrule",
    "name": String,
    "expression": <AtruleExpression> | <MediaQueryList> | <SelectorList> | <Raw> | null,
    "block": <Block> | null
}

AtruleExpression

{
    "type": "AtruleExpression",
    "children": List
}

AttributeSelector

{
    "type": "AttributeSelector",
    "name": <Identifier>,
    "operator": String | null,
    "value": <String> | <Identifier> | null,
    "flags": String | null
}

Block

{
    "type": "Block",
    "children": List
}

Brackets

{
    "type": "Brackets",
    "children": List
}

CDC

{
    "type": "CDC"
}

CDO

{
    "type": "CDO"
}

ClassSelector

{
    "type": "ClassSelector",
    "name": String
}

Combinator

{
    "type": "Combinator",
    "name": String
}

Comment

{
    "type": "Comment",
    "value": String
}

Declaration

{
    "type": "Declaration",
    "important": Boolean | String,
    "property": String,
    "value": <Value> | <Raw>
}

DeclarationList

{
    "type": "DeclarationList",
    "children": List
}

Dimension

{
    "type": "Dimension",
    "value": String,
    "unit": String
}

Function

{
    "type": "Function",
    "name": String,
    "children": List
}

HexColor

{
    "type": "HexColor",
    "value": String
}

IdSelector

{
    "type": "IdSelector",
    "name": String
}

Identifier

{
    "type": "Identifier",
    "name": String
}

MediaFeature

{
    "type": "MediaFeature",
    "name": String,
    "value": <Identifier> | <Number> | <Dimension> | <Ratio> | null
}

MediaQuery

{
    "type": "MediaQuery",
    "children": List
}

MediaQueryList

{
    "type": "MediaQueryList",
    "children": List
}

Nth

{
    "type": "Nth",
    "nth": <AnPlusB> | <Identifier>,
    "selector": <SelectorList> | null
}

Number

{
    "type": "Number",
    "value": String
}

Operator

{
    "type": "Operator",
    "value": String
}

Parentheses

{
    "type": "Parentheses",
    "children": List
}

Percentage

{
    "type": "Percentage",
    "value": String
}

PseudoClassSelector

{
    "type": "PseudoClassSelector",
    "name": String,
    "children": List | null
}

PseudoElementSelector

{
    "type": "PseudoElementSelector",
    "name": String,
    "children": List | null
}

Ratio

{
    "type": "Ratio",
    "left": String,
    "right": String
}

Raw

{
    "type": "Raw",
    "value": String
}

Rule

{
    "type": "Rule",
    "selector": <SelectorList> | <Raw>,
    "block": <Block>
}

SassInterpolation

{
    "type": "SassInterpolation",
    "children": List
}

SassPlaceholderSelector

{
    "type": "SassPlaceholderSelector",
    "name": String
}

SassVariable

{
    "type": "SassVariable",
    "name": String
}

Selector

{
    "type": "Selector",
    "children": List
}

SelectorList

{
    "type": "SelectorList",
    "children": List
}

String

{
    "type": "String",
    "value": String
}

StyleSheet

{
    "type": "StyleSheet",
    "children": List
}

TypeSelector

{
    "type": "TypeSelector",
    "name": String
}

UnicodeRange

{
    "type": "UnicodeRange",
    "value": String
}

Url

{
    "type": "Url",
    "value": <String> | <Raw>
}

Value

{
    "type": "Value",
    "children": List
}

WhiteSpace

{
    "type": "WhiteSpace",
    "value": String
}