0.0.1 • Published 8 years ago

posthtml-collect-styles v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Posthtml-collect-styles

NPM version Travis Build Status XO code style

Installation

$ npm i --save posthtml-collect-styles

Usage

<!-- index.html -->
<html>
<head>
</head>
<body>
  <style>.red {color: red;}</style>
  <style>.white {color: white;}</style>
</body>
</html>
/* index.js */
var fs = require('fs');
var posthtml = require('posthtml');

posthtml()
  .use(require('posthtml-collect-styles')('style'))
  .process(fs.readFileSync('index.html', 'utf8'))
  .then(function(result) {
    return result; 

    /**
     * <html>
     *  <head>
     *    <style>
     *      .red {color: red;}
     *      .white {color: white;}
     *    </style>
     *  </head>
     *  <body></body>
     * </html>
     */
  });

Api

selector: string: Selector to append styles, passed to posthtml-match-helper. default: 'head'.

License

MIT © Aleksandr Yakunichev