jonkemp / gulp-inline-css

Inline linked css in an html file. Useful for emails.
MIT License
272 stars 29 forks source link

Strips self-closing tags #6

Open jklegseth opened 10 years ago

jklegseth commented 10 years ago

Running the task on pages with self-closing tags and piping to another directory strips the "closing" part, i.e., <br /> becomes <br>.

Using a modified version of the HTML page you have in the README:

<html>
<head>
  <meta name="viewport" content="width=device-width" />
  <style>
    p { color: red; }
  </style>
</head>
<body>
  <p>Test<br />Is it still there?</p>
</body>
</html>

Note that the meta tag and the br are self-closing. And run this configuration:

gulp.task('inline', function() {
  return gulp.src('./tmp/*.html')
    .pipe(inlineCss())
    .pipe(gulp.dest('./dist'));;
});

The output is:

<html>
<head>
  <meta name="viewport" content="width=device-width">
</head>
<body>
  <p style="color: red;">Test<br>Is it still there?</p>
</body>
</html>

I played around with removeStyleTags and removeLinkTags but the problem didn't change.

jonkemp commented 10 years ago

Any issues with code formatting should be brought up with the juice2 module. Thanks.

https://github.com/andrewrk/juice

jonkemp commented 9 years ago

This may have changed now that this plugin relies on cheerio.js rather than jsdom.

mrshannonyoung commented 7 years ago

This is still an issue.

alexandr-kazakov commented 3 years ago

+1 I have the same problem.

alexandr-kazakov commented 3 years ago

Here's the solution:

In the node-modules>inline-css>lib folder, manually change the code in the file inline-css.js

From this code return decodeEntities($.html());

Make one: return decodeEntities($.xml());

Thank you to sgarbesi: https://github.com/jonkemp/gulp-inline-css/issues/28#issuecomment-159038975

Code_RMBiYHdd83