Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | # postcss-selector-parser [![Build Status](https://travis-ci.org/postcss/postcss-selector-parser.svg?branch=master)](https://travis-ci.org/postcss/postcss-selector-parser)
|
---|
2 |
|
---|
3 | > Selector parser with built in methods for working with selector strings.
|
---|
4 |
|
---|
5 | ## Install
|
---|
6 |
|
---|
7 | With [npm](https://npmjs.com/package/postcss-selector-parser) do:
|
---|
8 |
|
---|
9 | ```
|
---|
10 | npm install postcss-selector-parser
|
---|
11 | ```
|
---|
12 |
|
---|
13 | ## Quick Start
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const parser = require('postcss-selector-parser');
|
---|
17 | const transform = selectors => {
|
---|
18 | selectors.walk(selector => {
|
---|
19 | // do something with the selector
|
---|
20 | console.log(String(selector))
|
---|
21 | });
|
---|
22 | };
|
---|
23 |
|
---|
24 | const transformed = parser(transform).processSync('h1, h2, h3');
|
---|
25 | ```
|
---|
26 |
|
---|
27 | To normalize selector whitespace:
|
---|
28 |
|
---|
29 | ```js
|
---|
30 | const parser = require('postcss-selector-parser');
|
---|
31 | const normalized = parser().processSync('h1, h2, h3', {lossless: false});
|
---|
32 | // -> h1,h2,h3
|
---|
33 | ```
|
---|
34 |
|
---|
35 | Async support is provided through `parser.process` and will resolve a Promise
|
---|
36 | with the resulting selector string.
|
---|
37 |
|
---|
38 | ## API
|
---|
39 |
|
---|
40 | Please see [API.md](API.md).
|
---|
41 |
|
---|
42 | ## Credits
|
---|
43 |
|
---|
44 | * Huge thanks to Andrey Sitnik (@ai) for work on PostCSS which helped
|
---|
45 | accelerate this module's development.
|
---|
46 |
|
---|
47 | ## License
|
---|
48 |
|
---|
49 | MIT
|
---|
Note:
See
TracBrowser
for help on using the repository browser.