An open API service indexing awesome lists of open source software.

https://github.com/yacodes/posthtml-collect-styles

Move all styles tags' content to the head element
https://github.com/yacodes/posthtml-collect-styles

Last synced: about 2 months ago
JSON representation

Move all styles tags' content to the head element

Awesome Lists containing this project

README

        

# Posthtml-collect-styles

[![NPM version](http://img.shields.io/npm/v/posthtml-collect-styles.svg)](https://www.npmjs.org/package/posthtml-collect-styles)
[![Travis Build Status](https://travis-ci.org/canvaskisa/posthtml-collect-styles.svg)](https://travis-ci.org/canvaskisa/posthtml-collect-styles)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

## Installation
```console
$ npm i --save posthtml-collect-styles
```

## Usage
```html

.red {color: red;}
.white {color: white;}

```

```js
/* 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;

/**
*
*
*
* .red {color: red;}
* .white {color: white;}
*
*
*
*
*/
});
```
## Api
`selector: string`: Selector to append styles, passed to [posthtml-match-helper](https://github.com/rasmusfl0e/posthtml-match-helper). `default: 'head'`.

## License
MIT © [Aleksandr Yakunichev](https://github.com/canvaskisa)