jonkemp / jonkemp/inline-css

preserveMediaQueries: true still removes <styles>...</styles> from html.

Open
#88 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
438
Forks
77
PR merge metrics
No merged PRs in 30d

Description

In my code CSS is resolved from tag, if i place CSS in html and run, then tag are left intact, but when adding styles using tag then the styles are not resolved even though inline styles are applied, so preserveMediaQueries: true still removes styles. I am using http-server to run it, and node to create the html.

Here is the html

>




Here is the js

var inlineCss = require('inline-css');#
const fileName = 'test-inline.html'
var fs = require('fs'),
path = require('path'),
filePath = path.join(__dirname, fileName);

const inlineOptions = {
url: ' ',
preserveMediaQueries: true
};

// Read file
fs.readFile(filePath, {encoding: 'utf-8'}, function(err, html) {
if (!err) {
console.log('received html: ' + html);
// Inline css file contents to variable

inlineCss(html, inlineOptions)
.then((inlineHtml) => {
console.log(inlineHtml);
// Write inlined contents to file
fs.writeFile('inline-' + fileName, inlineHtml, (err) => {
if (err) {
return console.log(err);
}
console.log('write success');
});
});
} else {
console.log(err);
}
});

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.