gulp-inline-css icon indicating copy to clipboard operation
gulp-inline-css copied to clipboard

Strips self-closing tags

Open jklegseth opened this issue 10 years ago • 5 comments

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.

jklegseth avatar Jun 06 '14 22:06 jklegseth

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

https://github.com/andrewrk/juice

jonkemp avatar Jun 07 '14 03:06 jonkemp

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

jonkemp avatar Feb 08 '15 05:02 jonkemp

This is still an issue.

mrshannonyoung avatar Aug 18 '16 10:08 mrshannonyoung

+1 I have the same problem.

alexandr-kazakov avatar Jul 22 '20 11:07 alexandr-kazakov

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

alexandr-kazakov avatar Jul 22 '20 11:07 alexandr-kazakov