Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shellscape/postcss-values-parser
A CSS property value parser for PostCSS
https://github.com/shellscape/postcss-values-parser
css cssnext lesshint parse postcss postcss-values-parser values
Last synced: 2 days ago
JSON representation
A CSS property value parser for PostCSS
- Host: GitHub
- URL: https://github.com/shellscape/postcss-values-parser
- Owner: shellscape
- License: mpl-2.0
- Created: 2016-03-28T14:04:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-04T17:07:09.000Z (3 months ago)
- Last Synced: 2025-01-24T17:36:46.704Z (9 days ago)
- Topics: css, cssnext, lesshint, parse, postcss, postcss-values-parser, values
- Language: JavaScript
- Size: 1.03 MB
- Stars: 59
- Watchers: 6
- Forks: 31
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
README
[tests]: https://img.shields.io/circleci/project/github/shellscape/postcss-values-parser.svg
[tests-url]: https://circleci.com/gh/shellscape/postcss-values-parser[cover]: https://codecov.io/gh/shellscape/postcss-values-parser/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/shellscape/postcss-values-parser[size]: https://packagephobia.now.sh/badge?p=postcss-values-parser
[size-url]: https://packagephobia.now.sh/result?p=postcss-values-parser
# postcss-values-parser [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![size][size]][size-url]
A CSS property value parser built upon [PostCSS](https://github.com/postcss/postcss),
following the same node and traversal patterns as PostCSS.## Install
Using npm:
```console
npm install postcss-values-parser --save-dev
```Please consider [becoming a patron](https://www.patreon.com/shellscape) if you find this module useful.
## Requirements
`postcss-values-parser` Node version v6.14.0+ and PostCSS v7.0.0+.
## Benefits
- Leverages PostCSS and its tokenizer under the hood
- Doesn't strip characters; eg. parenthesis
- Full [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) traversal
- Ability to walk the AST for every Node type
- Convenience methods to stringify Nodes
- Follows PostCSS patterns for whitespace between Nodes
- Provides convenience properties for number units, colors, etc.## Usage
Using the parser is straightforward and minimalistic:
```js
const { parse } = require('postcss-values-parser');const root = parse('#fff');
const node = root.first;// → Word {
// raws: { before: '', after: '' },
// value: '#fff',
// type: 'word',
// isHex: true,
// isColor: true,
// isVariable: false,
// ...
// }
```Please see the [Documentation](./docs/README.md) for further information on using the module.
## Meta
[CONTRIBUTING](./.github/CONTRIBUTING.md)
[LICENSE (Mozilla Public License)](./LICENSE)