JSPM

  • Created
  • Published
  • Downloads 32420897
  • Score
    100M100P100Q218132F
  • License MIT

Fast detailed CSS parser

Package Exports

  • css-tree
  • css-tree/data
  • css-tree/data/patch.json
  • css-tree/dist/csstree
  • css-tree/dist/default-syntax.json
  • css-tree/lib/lexer/grammar/parse
  • css-tree/lib/utils/list

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (css-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CSSTree logo

CSSTree

NPM version Build Status Coverage Status Join the CSSTree chat at https://gitter.im/csstree/csstree Twitter

The set of tools for working with CSS, including fast detailed parser (string->AST), walkers, generators (AST->string) and even lexer (validation and matching) based on knowledge of spec and browser implementations (see schema for details). The main goal to be efficient and W3C spec complient, with focus on analyzing and source-to-source processing.

Work in progress. The project in alpha stage since some parts need further experiments, AST format and API are subjects to change. However it's stable enough and used by packages like CSSO (CSS minifier) in production.

Docs and tools:

Related projects:

Install

> npm install css-tree

Usage

var csstree = require('css-tree');
var ast = csstree.parse('.example { world: "!" }');

csstree.walk(ast, function(node) {
    if (node.type === 'ClassSelector' && node.name === 'example') {
        node.name = 'hello';
    }
});

console.log(csstree.translate(ast));
// .hello{world:"!"}

Top level API

API map

License

MIT

Syntax matching uses mdn/data by Mozilla Contributors