GitHub - nDmitry/postcss: Framework for CSS postproccessors · GitHub
Skip to content

nDmitry/postcss

 
 

Folders and files

Repository files navigation

PostCSS

PostCSS is a framework for CSS postprocessors. You gives custom JS function to modify CSS and PostCSS parses CSS, gives your usable JS API to edit CSS nodes tree and then save modified nodes tree to new CSS.

For example, lets fix forgotten content ptopery in ::before and ::after:

var postcss = require('postcss');

var postprocessor = postcss(function (css) {
    css.eachRule(function (rule) {
        if ( rule.selector.match(/::(before|after)/) ) {

            var good = rule.decls.some(function (i) {
                return i.prop == 'content';
            });
            if ( !good ) {
                rule.prepend({ prop: 'content', value: '""' });
            }

        }
    });
});

And then CSS with forgotten content:

a::before {
    width: 10px;
    height: 10px;
    background: black
}

will be fixed by our new postprocessor:

var fixed = postprocessor.process(css);

to:

a::before {
    content: "";
    width: 10px;
    height: 10px;
    background: black
}

Sponsored by Evil Martians.

About

Framework for CSS postproccessors

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

  • CoffeeScript 95.9%
  • CSS 4.1%