Skip to content

Commit 040a0ea

Browse files
committed
docs
1 parent 8206d53 commit 040a0ea

File tree

1 file changed

+82
-31
lines changed

1 file changed

+82
-31
lines changed

Readme.md

Lines changed: 82 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,37 @@
55

66
## Example
77

8-
js:
8+
css:
99

10-
```js
11-
var parse = require('css-parse')
12-
parse('tobi { name: "tobi" }')
10+
```css
11+
body {
12+
background: #eee;
13+
color: #888;
14+
}
1315
```
1416

15-
object returned:
17+
parse tree:
1618

1719
```json
1820
{
21+
"type": "stylesheet",
1922
"stylesheet": {
2023
"rules": [
2124
{
22-
"selectors": ["tobi"],
25+
"type": "rule",
26+
"selectors": [
27+
"body"
28+
],
2329
"declarations": [
2430
{
25-
"property": "name",
26-
"value": "tobi"
31+
"type": "declaration",
32+
"property": "background",
33+
"value": "#eee"
34+
},
35+
{
36+
"type": "declaration",
37+
"property": "color",
38+
"value": "#888"
2739
}
2840
]
2941
}
@@ -32,31 +44,70 @@ object returned:
3244
}
3345
```
3446

35-
## Performance
36-
37-
Parsed 15,000 lines of CSS (2mb) in 40ms on my macbook air.
38-
39-
## License
47+
parse tree with `.position` enabled:
4048

41-
(The MIT License)
49+
```json
50+
{
51+
"type": "stylesheet",
52+
"stylesheet": {
53+
"rules": [
54+
{
55+
"type": "rule",
56+
"selectors": [
57+
"body"
58+
],
59+
"declarations": [
60+
{
61+
"type": "declaration",
62+
"property": "background",
63+
"value": "#eee",
64+
"position": {
65+
"start": {
66+
"line": 3,
67+
"column": 3
68+
},
69+
"end": {
70+
"line": 3,
71+
"column": 19
72+
}
73+
}
74+
},
75+
{
76+
"type": "declaration",
77+
"property": "color",
78+
"value": "#888",
79+
"position": {
80+
"start": {
81+
"line": 4,
82+
"column": 3
83+
},
84+
"end": {
85+
"line": 4,
86+
"column": 14
87+
}
88+
}
89+
}
90+
],
91+
"position": {
92+
"start": {
93+
"line": 2,
94+
"column": 1
95+
},
96+
"end": {
97+
"line": 5,
98+
"column": 2
99+
}
100+
}
101+
}
102+
]
103+
}
104+
}
105+
```
42106

43-
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
107+
## Performance
44108

45-
Permission is hereby granted, free of charge, to any person obtaining
46-
a copy of this software and associated documentation files (the
47-
'Software'), to deal in the Software without restriction, including
48-
without limitation the rights to use, copy, modify, merge, publish,
49-
distribute, sublicense, and/or sell copies of the Software, and to
50-
permit persons to whom the Software is furnished to do so, subject to
51-
the following conditions:
109+
Parsed 15,000 lines of CSS (2mb) in 40ms on my macbook air.
52110

53-
The above copyright notice and this permission notice shall be
54-
included in all copies or substantial portions of the Software.
111+
## License
55112

56-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
57-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
59-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
60-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
61-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
62-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
113+
MIT

0 commit comments

Comments
 (0)