Rehype plugin to embed a stylesheet to each html elements.
npm install rehype-inline-css
import { unified } from 'unified'
import rehype from 'rehype-parse'
import stringify from 'rehype-stringify'
import inlineCss from './index.js'
const processor = unified().use(rehype).use(inlineCss).use(stringify)
const i = `<p>test</p><style>p { color: red; }</style>`
const o = processor.processSync(i).toString()
cosnole.log(o)
Now running the above script yields:
<p style="color: red;">test</p>
rehype().use(inlineCss)
This plugin embeds all stylesheets in documents. Please take care of Suspicious stylesheets.
MIT © TANIGUCHI Masaya