Giter VIP home page Giter VIP logo

css-extractor's Introduction

css-extractor

๐Ÿ’Ž extracts class names and ids from CSS

Installing

$ npm install css-extractor

Basic Usage

var extractor = require('css-extractor');

var css = "#id, .class { color:#000 }";

extractor.extract(css);
// => ['#id','.class']

extract will return an array of all unique class names and ids

Approach

This module was designed to be lightweight, with no dependencies, using RegExp patterns to trim the input CSS content and capture the class names and ids.

Testing

Tests are performed using the tap testing framework. To run:

$ npm install
$ npm test

The main focus of the test cases is to ensure compatibility with common and uncommon syntactic features and liberties available in CSS, including:

  • @media queries
  • attribute selectors: #id[href='#id-like']
  • arbitrary and non-mandatory spacing
  • comment blocks

For more on such cases, check out the .css files in test\fixtures

css-extractor's People

Contributors

json2d avatar

Stargazers

 avatar

Watchers

 avatar  avatar

css-extractor's Issues

Doesn't extract some classes

Doesn't extract .field nor .is-horizontal from this structure, taken from Bulma

@media screen and (min-width: 769px), print {
  .field.is-horizontal {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.