juice icon indicating copy to clipboard operation
juice copied to clipboard

Option to not escape double quotes, & etc

Open bilalkinnek opened this issue 9 years ago • 3 comments

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?

bilalkinnek avatar Nov 06 '14 01:11 bilalkinnek

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

jrit avatar Nov 25 '14 03:11 jrit

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>

jsakas avatar Dec 11 '14 08:12 jsakas

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.

jrit avatar Dec 13 '14 17:12 jrit