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)
3 > Selector parser with built in methods for working with selector strings.
7 With [npm](https://npmjs.com/package/postcss-selector-parser) do:
10 npm install postcss-selector-parser
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))
24 const transformed = parser(transform).processSync('h1, h2, h3');
27 To normalize selector whitespace:
30 const parser = require('postcss-selector-parser');
31 const normalized = parser().processSync('h1, h2, h3', {lossless: false});
35 Async support is provided through `parser.process` and will resolve a Promise
36 with the resulting selector string.
40 Please see [API.md](API.md).
44 * Huge thanks to Andrey Sitnik (@ai) for work on PostCSS which helped
45 accelerate this module's development.