andrewrk / juice

Juice inlines CSS stylesheets into your HTML source.
MIT License
60 stars 13 forks source link

Option to not escape double quotes, & etc #17

Open bilalkinnek opened 10 years ago

bilalkinnek commented 10 years ago

I am using juice with templates which have a bunch of server side tags, and its escaping double quotes, & etc even when they are not in the style/class tags. Is there any way to turn off auto escaping?

jrit commented 9 years ago

Can you supply a simple example of what the input and output is where this happens?

jsakas commented 9 years ago

Hi, I can't get the available tests running at the moment so I quickly created my own to demonstrate. I can confirm this issue and would like to help get it fixed. Here's what I've got, hopefully it makes sense:

./test/html/ampersand.in.html

<p>hi, this is an ampersand: &</p>

./juice-test.js

var juice = require("./index.js")
juice("./test/html/ampersand.in.html", function(err, html) {
  console.log(html);
});

run from terminal / output

$ node juice-test.js
<html><body><p>hi, this is an ampersand: &amp;</p>

</body></html>
jrit commented 9 years ago

I'm pretty sure the reason this happens is because the whole document is read into jsdom and then later pulled back out from its innerHTML and jsdom does some character escaping and formatting changes along the way. I've had some similar problems where &mdash; gets turned into unicode. Likely resolutions may be updating jsdom or possibly some future version of Juice that doesn't depend on jsdom. At the moment I'm working on updating some related things and will try to resolve this afterwards if no resolution is suggested in the meantime.