html-embed-stylesheets
Insert html and receive back html with all stylesheets embedded. Can resolve relative urls inside stylesheets to a given root url.
Improvements
- consider @import statements inside stylesheets
- improve css url regex to not capture whitespace after uri, e.g. in case of
url( https://img.itch.zone/aW1hZ2UvMTgyMjY4Lzg1MTg3MC5wbmc=/300x240%23c/EWraUT.png );
Table of Contents
embedStylesheets
Insert html and receive back html with all stylesheets embedded. Can resolve relative urls inside stylesheets to a given root url.
Parameters
html
string the HTML to parse for stylesheetsopts
{resolveTo: string, download: Boolean} object with options.resolveTo
defines to which root url discovered urls in stylesheets should be resolved.download
defines whether resolved stylesheets should be downloaded and embedded, defaults to true.
Examples
const embedStylesheets = { const html = await console}
Returns {html: string, stylesheetUrls: [string], stylesheets: [string]} an object returning the html with stylesheets embedded, an array of unique stylesheet urls that were found, and an array of stylesheets with inner urls resolved.