Skip to content

Commit 9878be0

Browse files
committed
updated readme
1 parent aa7e85a commit 9878be0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

readme.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
11
#CSSwhat [![Build Status](https://secure.travis-ci.org/fb55/CSSwhat.png?branch=master)](http://travis-ci.org/fb55/CSSwhat)
22

33
a CSS selector parser
4+
5+
##Example
6+
7+
```js
8+
require("CSSwhat")("foo[bar]:baz")
9+
10+
~> [ [ { type: 'tag', name: 'foo' },
11+
{ type: 'attribute',
12+
name: 'bar',
13+
action: 'exists',
14+
value: '',
15+
ignoreCase: false },
16+
{ type: 'pseudo',
17+
name: 'baz',
18+
data: null } ] ]
19+
```
20+
21+
##API
22+
23+
__`CSSwhat(selector, options)` - Parses `str`, with the past `options`.__
24+
25+
The function returns a two-dimensional array. The first array represents subselects separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
26+
27+
name | attributes | example | output
28+
---- | ---------- | ------- | ------
29+
`tag`| `name` | `div` | `{ type: 'tag', name: 'div' }`
30+
`universal`| - | `*` | `{ type: 'universal' }`
31+
32+
//TODO complete list
33+
34+
__Options:__
35+
36+
- `xmlMode`: When enabled, tagnames will be case-sensitive (ie. the output won't be lowercased).
37+
38+
---
39+
40+
License: BSD-like

0 commit comments

Comments
 (0)