Socket
Book a DemoInstallSign in
Socket

css-tree

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-tree

Fast detailed CSS parser

Source
npmnpm
Version
1.0.0-alpha20
Version published
Weekly downloads
20M
-27.64%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

css

FAQs

Package last updated on 28 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts