posthtml-inline-css
PostHTML plugin for inlining CSS to style attrs
Usage
Plain CSS
var posthtml = require('posthtml'),
css = 'div { color: red }';
posthtml([require('posthtml-inline-css')(css)])
.process('<div style="font-size: 14px">Hello!</div>')
.then(function (result) {
console.log(result.html);
});
<style>
var posthtml = require('posthtml'),
html = '<style>div { color: red }</style><div>Hello!</div>';
posthtml([require('posthtml-inline-css')()])
.process(html)
.then(function (result) {
console.log(result.html);
});
PostCSS
var posthtml = require('posthtml'),
postcss = require('postcss'),
postcssObj = postcss().process('div { color: white }');
posthtml([require('posthtml-inline-css')(postcssObj)])
.process('<div style="font-size: 14px">Hello!</div>')
.then(function (result) {
console.log(result.html);
});