项目作者: shellscape

项目描述 :
A CSS property value parser for PostCSS
高级语言: JavaScript
项目地址: git://github.com/shellscape/postcss-values-parser.git
创建时间: 2016-03-28T14:04:43Z
项目社区:https://github.com/shellscape/postcss-values-parser

开源协议:Mozilla Public License 2.0

下载






postcss-values-parser tests cover size

A CSS property value parser built upon PostCSS,
following the same node and traversal patterns as PostCSS.

Install

Using npm:

  1. npm install postcss-values-parser --save-dev



Please consider becoming a patron 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 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:

  1. const { parse } = require('postcss-values-parser');
  2. const root = parse('#fff');
  3. const node = root.first;
  4. // → Word {
  5. // raws: { before: '', after: '' },
  6. // value: '#fff',
  7. // type: 'word',
  8. // isHex: true,
  9. // isColor: true,
  10. // isVariable: false,
  11. // ...
  12. // }

Please see the Documentation for further information on using the module.

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)