You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A CSS property value parser built upon [PostCSS](https://github.com/postcss/postcss),
15
-
following the same node and traversal patterns as PostCSS.
12
+
A CSS property value parser that uses [css-tree](https://github.com/csstree/csstree) for parsing,
13
+
and models nodes on top of PostCSS’s `Node`/`Container`/`Root` classes so the API feels familiar to PostCSS users.
16
14
17
15
This package powers part of [Prettier](https://prettier.io/). Please consider becoming a sponsor if you find this package useful or are a Prettier user. https://github.com/sponsors/shellscape
Copy file name to clipboardExpand all lines: docs/Comment.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Comment Node
2
2
3
-
The `Comment` node inherits directly from `Node` in PostCSS. This node represents a CSS comment; either inline (`//`) or block (`/* */`).
3
+
The `Comment` node inherits directly from `Node` in PostCSS. This node represents a CSS block comment(`/* … */`).
4
4
5
5
## Properties
6
6
7
7
### `inline`
8
8
9
9
Type: `Boolean`<br>
10
10
11
-
If `true`, indicates that the type of comment is "inline," or a comment that begins with `//`. If `false`, indicates that the comment is a traditional block comment.
11
+
Always `false` for CSS values. Inline `//` comments are not part of standard CSS values and are not produced by the parser.
12
12
13
13
### `text`
14
14
@@ -25,11 +25,10 @@ Value: `'comment'`
25
25
26
26
Type: `String`<br>
27
27
28
-
A `String` representation of the original comment including comment markers.
28
+
The original comment including comment markers, e.g. `/* comment */`.
Copy file name to clipboardExpand all lines: docs/Exports.md
+16-66Lines changed: 16 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# Exported Methods
1
+
# Exported API
2
2
3
3
This module exports the following methods and classes:
4
4
5
-
### `parse(css, options)`
5
+
### `parse(css, options?)`
6
6
7
7
Returns: `Root`<br>
8
8
9
-
Parses a given `String` and returns an AST with a `Root` node. If the input is an invalid CSS value, a `ParseError` is thrown.
9
+
Parses a given string and returns an AST with a `Root` node. If the input is an invalid CSS value, a `ParseError` is thrown.
10
10
11
11
#### Parameters
12
12
@@ -17,36 +17,13 @@ _Required_
17
17
18
18
#### `options`
19
19
20
-
Type: `ParseOptions`<br>
21
-
_Optional_
20
+
Type: `ParseOptions` (optional)
22
21
23
-
##### Properties
24
-
25
-
##### `ignoreUnknownWords`
26
-
27
-
Type: `Boolean`<br>
28
-
Default: `false`
29
-
30
-
If `true`, will allow all unknown parts of the value to be parsed and added to the AST. If `false`, unknown values will throw `ParseError`.
31
-
32
-
##### `interpolation`
33
-
34
-
Type: `Boolean|InterpolationOptions`<br>
35
-
Default: `false`
36
-
37
-
Set this option to enable parsing of interpolated values for languages such as SCSS. For example:
38
-
`interpolation: { prefix: '@' }` will allow parsing of the interpolated value `@{batman}` which uses `@` as the "prefix". For SCSS one might use `interpolation: { prefix: '#' }`.
39
-
40
-
##### `variables`
41
-
42
-
Type: `VariablesOptions`<br>
43
-
Default: `{ prefixes: ['--'] }`
44
-
45
-
Set this option to modify how variables are identified in a value. By default, this option is set to recognize CSS variables. For languages such as LESS and SCSS which have their own variable prefixes, additional prefixes can be added to the `prefixes` array.
22
+
Reserved for future use. In v7, options are accepted by the signature but are not used by the parser.
46
23
47
24
### `stringify(node, builder)`
48
25
49
-
A `Function` with a signature matching `(bit) => {}`used to concatenate or manipulate each portion (or bit) of the Node's own AST. The `nodeToString`method makes use of this, as a simple example.
26
+
A function used to concatenate or manipulate each portion (or bit) of a node during stringification. The `nodeToString`helper uses this under the hood.
50
27
51
28
#### Parameters
52
29
@@ -79,7 +56,7 @@ Returns: `String`
79
56
80
57
### `registerWalkers(Container)`
81
58
82
-
Registers custom walker methods on the Container prototype to enable walking specific node types. This function is called automatically when the module is loaded, but can be called manually if needed.
59
+
Registers custom walker methods on the Container prototype to enable walking specific node types. This function is not called automatically; call it once before using any `walk*` helpers.
83
60
84
61
#### Parameters
85
62
@@ -92,7 +69,7 @@ The Container class to register walker methods on.
92
69
93
70
## Exported Classes
94
71
95
-
All Node classes are exported and can be imported individually:
72
+
All node classes are exported and can be imported individually:
96
73
97
74
### Node Classes
98
75
@@ -116,40 +93,16 @@ All Node classes are exported and can be imported individually:
116
93
117
94
### Type Definitions
118
95
119
-
-`ParseOptions` - Options interface for the parse function
120
-
-`InterpolationOptions` - Options for interpolation parsing
121
-
-`VariablesOptions` - Options for variable recognition
96
+
-`ParseOptions` - Placeholder in v7 (forward‑compatibility)
122
97
-`Stringifier` - Function interface for custom stringifiers
123
98
-`Builder` - Function interface for string building during stringify
124
99
-`NodeOptions` - Options interface for node construction
125
100
126
-
## Type Interfaces
101
+
## Types
127
102
128
103
### `ParseOptions`
129
104
130
-
```typescript
131
-
interfaceParseOptions {
132
-
ignoreUnknownWords?:boolean;
133
-
interpolation?:boolean|InterpolationOptions;
134
-
variables?:VariablesOptions;
135
-
}
136
-
```
137
-
138
-
### `InterpolationOptions`
139
-
140
-
```typescript
141
-
interfaceInterpolationOptions {
142
-
prefix:string;
143
-
}
144
-
```
145
-
146
-
### `VariablesOptions`
147
-
148
-
```typescript
149
-
interfaceVariablesOptions {
150
-
prefixes:string[];
151
-
}
152
-
```
105
+
An empty placeholder interface in v7. Kept for forward‑compatibility.
0 commit comments