-
Notifications
You must be signed in to change notification settings - Fork 188
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
premailer doesn't appear to work on m1 macs #249
Comments
@davidfwatson could you add the content of example_html.html or some other file that reproduces the problem? |
I think the issue is unicode characters! I've created an example, and attached it. |
import premailer
with open('/Users/peterbe/Downloads/example_html.html/example_html.html') as f:
html = f.read()
out = premailer.transform(
html,
)
print(out) outputs:
By the way, it's supposed to be: -<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> in case that matters to your other tooling. |
So, on my m1 mac, I don't get that, output, I get this:
|
Here's what I get:
I have...:
What do you have? And do you have the
|
|
@davidfwatson Just for sanity checking, what do you get when you run:
|
|
I'm at loss then. I don't know what could be going on. I have seen really strange behaviors coming out of |
So you’re getting good results on an m1 Mac?
…On Fri, Jun 25, 2021 at 11:50 Peter Bengtsson ***@***.***> wrote:
I'm at loss then. I don't know what could be going on.
I have seen really strange behaviors coming out of lxml before when
emojiis are involved.
It would be nice to be able to understand when that HTML string, after
being read in, becomes garble. And if any of that is related to premailer
or somewhere else.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#249 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYE3KCNEEJSC3C3PVFVXPLTUTFWVANCNFSM4YBSUTRQ>
.
|
I don’t have m1 Mac :(
It would be interesting to install that exact version of lxml on mine to
see if it matters. Or if you try to up- or downgrade lxml to see if the
problem goes away.
On Fri, Jun 25, 2021 at 4:35 PM davidfwatson ***@***.***>
wrote:
So you’re getting good results on an m1 Mac?
On Fri, Jun 25, 2021 at 11:50 Peter Bengtsson ***@***.***>
wrote:
> I'm at loss then. I don't know what could be going on.
>
> I have seen really strange behaviors coming out of lxml before when
> emojiis are involved.
> It would be nice to be able to understand when that HTML string, after
> being read in, becomes garble. And if any of that is related to premailer
> or somewhere else.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#249 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/AAYE3KCNEEJSC3C3PVFVXPLTUTFWVANCNFSM4YBSUTRQ
>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#249 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAGQ427CIXQSXM6NH3YTTLTUTSAJANCNFSM4YBSUTRQ>
.
--
Peter Bengtsson
Mozilla MDN Web Docs
https://www.peterbe.com
|
I can give that a shot, but just to be clear, I ran it on my intel mac with identical versions and it did work. I'll try to find time to match your versions and rerun today, but I suspect the result will be the same. |
I'm running into this identical issue on a M1 mac as well. python3 --version |
Can we try to figure out if |
I downgraded lxml and it's working for me with version |
Sorry to report, but it doesn't appear to have made a difference for me:
|
This does appear to be a bug in Here's the lxml bug: https://bugs.launchpad.net/lxml/+bug/1949271 The bug report reveals that a workaround is to use UTF-16 or UTF-32 instead of UTF-8. Instead of
this works for me:
It ain't pretty, but at least it works. |
I'm able to use html entity encoding as a workaround. (I guess anything that avoids lxml having to deal with utf-8 input...) >>> from premailer import transform
>>> html = "<p>🌐</p>"
>>> transform(html)
Traceback (most recent call last):
...
File ".../python3.11/site-packages/premailer/premailer.py", line 353, in transform
tree = etree.fromstring(stripped, parser).getroottree()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'getroottree'
>>> html.encode("ascii", "xmlcharrefreplace").decode("ascii")
'<p>🌐</p>'
>>> transform(html.encode("ascii", "xmlcharrefreplace").decode("ascii"))
'<html>\n<head></head>\n<body><p>🌐</p></body>\n</html>\n' Premailer 3.10.0, lxml 4.9.2, Python 3.11.1 |
Running premailer on an m1 mac with pretty standard html content works correctly on my 2019 imac, but on my m1 mac, it results in garbage output:
❯ python -m premailer -f example_html.html
h t m l l a n g = " e n " >
%The text was updated successfully, but these errors were encountered: