juice icon indicating copy to clipboard operation
juice copied to clipboard

Juice not removing all <style>

Open phstc opened this issue 1 year ago • 1 comments

I'm trying to remove all <style> from an HTML, but juice is keeping some out.

If I paste the HTML on the demo website it removes all <style> 🤷‍♂️

I'm using juice 9.1.0.

Sample RunKit https://runkit.com/embed/fjqdnm3ckkdv (change the output from Rendered HTML to Full Text)

const fs = require('fs');
const juice = require('juice');

const rawHtml = `
  <!DOCTYPE html>
  <html>
  <head>
    <style>
a:hover {
  color: #000 !important;
}
a:active {
  color: #000 !important;
}
a:visited {
  text-decoration: none;
  color: #00c8b4 !important;
}
@media only screen and (max-width: 600px) {
  table[class="body"] img {
    height: auto !important;
    width: auto !important;
  }
}

    </style>
  </head>
  <body>
    Test!!!
  </body>
  </html>
`;

const juiceHtml = juice(rawHtml)
console.log(juiceHtml)

/*

OUTPUT:

  <!DOCTYPE html>
  <html>
  <head>
    <style>
a:hover {
  color: #000 !important;
}
a:active {
  color: #000 !important;
}
a:visited {
  text-decoration: none;
  color: #00c8b4 !important;
}
@media only screen and (max-width: 600px) {
  table[class="body"] img {
    height: auto !important;
    width: auto !important;
  }
}
</style>
  </head>
  <body>
    Test!!!
  </body>
  </html>


*/

Any ideas on what it could be?

I did try with the same options as on the demo website, but still, it did not work. The most important option is removeStyleTags, but that's true by default.

phstc avatar Aug 02 '23 04:08 phstc