Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does Premailer convert ASCII code into symbols/characters? #30

Closed
adamt19 opened this issue Feb 23, 2011 · 20 comments
Closed

Why does Premailer convert ASCII code into symbols/characters? #30

adamt19 opened this issue Feb 23, 2011 · 20 comments
Labels

Comments

@adamt19
Copy link

adamt19 commented Feb 23, 2011

Premailer converts [& copy ;](without spaces) to ©, [& quot ;] to ", [& amp ;] to &.. and I can't imagine a use case where this would be helpful. I've emailed Alex about this and I believe he told me that some people want it different ways.

I don't get it - this takes a perfectly-validated email transmission, and leaves with potentially hundreds of validation errors.

It makes premailer no-longer a useful tool for us, and I imagine most people, at all.

WHO are the people that told Alex they needed premailer to behave like this? Are they a majority?

@alexdunae
Copy link
Contributor

Nobody told me that -- it's just an artifact of Hpricot, the HTML parser used by Premailer. It's definitely on my list fix.

@davidrivers
Copy link

Will this be fixed soon? This is unfortunately a deal-breaker for my team, too :(

@akzhan
Copy link
Member

akzhan commented Mar 26, 2011

It looks that resolved because we can now use Nokogiri parser instead of Hpricot.

I wait for release :)

@adamt19
Copy link
Author

adamt19 commented Mar 26, 2011

Can't wait! :)

On Sat, Mar 26, 2011 at 1:24 PM, akzhan <
reply@reply.github.com>wrote:

It looks that resolved because we can now use Nokogiri parser instead of
Hpricot.

I wait for release :)

Reply to this email directly or view it on GitHub:
https://github.com/alexdunae/premailer/issues/30#comment_920679

@akzhan
Copy link
Member

akzhan commented Mar 26, 2011

alexdunae, any estimations about premailer release with Nokogiri integration?

@alexdunae
Copy link
Contributor

@akzhan -- Tuesday at the latest. I'd like to finish getting the test suite up to scratch.

@akzhan
Copy link
Member

akzhan commented Mar 26, 2011

Good news. We/ll plan to release later :)

@adamt19
Copy link
Author

adamt19 commented Apr 13, 2011

Hey Alex, we noticed the change to the new parser, but then it seems things have been reverted?

@adamt19 adamt19 closed this as completed Apr 13, 2011
@adamt19
Copy link
Author

adamt19 commented Apr 13, 2011

Hey Alex, we noticed the change to the new parser, but then it seems things have been reverted?

@adamt19 adamt19 reopened this Apr 13, 2011
@akzhan
Copy link
Member

akzhan commented May 6, 2011

Send :adapter => :nokogiri option to Premailer.new to use alternate (and more effective) parser.

@adamt19
Copy link
Author

adamt19 commented Sep 8, 2011

Sorry for the newb question, but could someone be more specific as to what I'd need to do in order to use nokogiri? We're using the bookmarklet right now, but if I can host a modified version of the script on my own, I'd like to do so -- at least until v2! Thx

@alexdunae
Copy link
Contributor

I've added a Nokogiri option to http://premailer.dialect.ca/ -- I'll take a look at how to create an option via the bookmarklet.

@alexdunae alexdunae reopened this Sep 9, 2011
@mehas
Copy link

mehas commented Oct 19, 2011

The Nokogiri parser still has the same problem. For example, &#8217; is converted to after being run through Premailer using the Nokogiri parser.

What's more, it appends &#13; to the end of every line.

@egid
Copy link

egid commented Nov 4, 2011

As I commented in issue 92 (duplicate), the temporary, hacky workaround seems to be to remove the charset from your meta tag.

I am now using <meta http-equiv="Content-Type" content="text/html" /> without issues.

@parxier
Copy link

parxier commented Oct 3, 2013

another dup #148?

@akzhan
Copy link
Member

akzhan commented Oct 23, 2013

another dup #160

@pduersteler
Copy link

Is there something we can do to resolve this issue? Do we know where the actual problem is? I'd invest time and create a pull request, since I need to have this worked out. Removing a charset line and/or adding <meta http-equiv="Content-Type" content="text/html" /> didn't helped, neither did setting adapter: :nokogiri.

I just checked out the charset-branch to test things, and the problem does not appear there. I am not sure how accurate a compare is, but maybe this gives some hints on where to look: https://github.com/premailer/premailer/compare/charset

@amclin
Copy link
Contributor

amclin commented Mar 6, 2014

I ran into this suddenly today when setting up my build system on a new machine.

  • When using Hpricot, html encoded characters &reg;``&copy; are preserved
  • When using Nokogiri, html encoded characters &reg;``&copy; are converted to UTF-8 ®``©

@amclin
Copy link
Contributor

amclin commented Mar 6, 2014

So apparently Nokogiri always rewrites HTML entities to UTF-8 characters. You can get HTML entities back using doc.to_html(encoding:'US-ASCII')

http://stackoverflow.com/questions/7756123/nokogiri-leaving-html-entities-untouched

It won't give you the friendly-name entity &copy; but at least it will give you a working entity &#169;

@akzhan
Copy link
Member

akzhan commented Jun 28, 2016

Closed due to #181.

@akzhan akzhan closed this as completed Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants