@@ -16,8 +16,8 @@ var css = "body { \n background-color: #fff;\n }";
16
16
17
17
var output_obj = parse (css);
18
18
19
- // Filename parameter for source mapping
20
- var output_obj_pos = parse (css, { filename : ' file.css' });
19
+ // Source parameter to specify source file name for source maps
20
+ var output_obj_pos = parse (css, { source : ' file.css' });
21
21
22
22
// Print parsed object as CSS string
23
23
console .log (JSON .stringify (output_obj, null , 2 ));
@@ -30,7 +30,7 @@ console.log(JSON.stringify(output_obj, null, 2));
30
30
31
31
` options ` :
32
32
33
- - ` filename ` - recommended for debugging.
33
+ - ` source ` - recommended for debugging.
34
34
- ` position ` - ` true ` by default.
35
35
36
36
### Errors
@@ -39,8 +39,7 @@ Errors will have `err.position` where `position` is:
39
39
40
40
- ` start ` - start line and column numbers
41
41
- ` end ` - end line and column numbers
42
- - ` filename ` - filename if passed to options
43
- - ` source ` - source CSS string
42
+ - ` source ` - ` options.source ` if passed to options
44
43
45
44
If you create any errors in plugins such as in [ rework] ( https://github.com/reworkcss/rework ) , you __ must__ set the ` position ` as well for consistency.
46
45
@@ -145,17 +144,18 @@ parse tree with `.position` enabled:
145
144
}
146
145
```
147
146
148
- If you also pass in ` filename: 'path/to/original.css' ` , that will be set
149
- on ` node.position.filename ` .
147
+ ` node.position.content ` is set on each node to the full source string. If you
148
+ also pass in ` source: 'path/to/original.css' ` , that will be set on
149
+ ` node.position.source ` .
150
150
151
151
## Performance
152
152
153
153
Parsed 15,000 lines of CSS (2mb) in 40ms on my macbook air.
154
154
155
155
## Related
156
-
157
- [ css-stringify] ( https://github.com/visionmedia/css-stringify " CSS-Stringify ")
158
- [ css-value] ( https://github.com/visionmedia/css-value " CSS-Value ")
156
+
157
+ [ css-stringify] ( https://github.com/visionmedia/css-stringify " CSS-Stringify ")
158
+ [ css-value] ( https://github.com/visionmedia/css-value " CSS-Value ")
159
159
160
160
## License
161
161
0 commit comments