posthtml-collect-styles
v0.0.1
Published
Collect styles from html and put it in the head
Downloads
63
Maintainers
Readme
Posthtml-collect-styles
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