dlanger / inlinestyler Goto Github PK
View Code? Open in Web Editor NEWA simple CSS inliner for generating HTML email messages.
Home Page: http://pypi.python.org/pypi/inlinestyler
License: BSD 3-Clause "New" or "Revised" License
A simple CSS inliner for generating HTML email messages.
Home Page: http://pypi.python.org/pypi/inlinestyler
License: BSD 3-Clause "New" or "Revised" License
It is possible to embed CSS inside the <style>
element using the data: URI scheme. Like this:
<link rel="stylesheet" href="data:text/css,EMBEDDED_CSS_GOES_HERE">
This worked in 0.2.0, but doesn’t work in 0.2.1 with the move from urllib.urlopen() to python-requests.
It’d be nice to get this working again, though it’s arguably a requests issue.
I took a quick at requests, but I couldn’t determine if they have support for RFC 2397 (which defines the data: scheme).
I suggest leaving this bug open until either of us the time to investigate RFC2397 support in python-requests.
Hi!
First of all - thanks for this really nice and helpful library!
It's not a bug, rather a feature request.
I'm getting tons of warnings like those:
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
WARNING Property: Unknown Property name.
Is there a way to silence them? I couldn't find any verbose option.
Thanks!
Daniel
Hey Daniel,
would you mind updating the package in the pip repository?
There's still the version that depends on django.
THX! :-)
Updating from 0.2.1 to 0.2.2 breakes on Python 3.4
File "/env/lib/python3.4/site-packages/inlinestyler/utils.py", line 17, in inline_css
converter.perform(document, html_message, '', encoding=encoding)
File "/env/lib/python3.4/site-packages/inlinestyler/converter.py", line 62, in perform
self.convertedHTML = etree.tostring(document, method="html", pretty_print=True).encode(encoding)
AttributeError: 'bytes' object has no attribute 'encode'
Hello!
I use inlinestyler for preprocessing mustache-templates for emails.
Initial template has this link: <a href="{{config.url}}">Home</a>
And inline_css method encodes href: <a href="%7B%7Bconfig.url%7D%7D">Home</a>
After that mustache can't handle this template.
Version 0.2.1 doesn't have this issue. 0.2.2 and 0.2.3 - have
This code crashes with a NotImplemented exception.
from inlinestyler.utils import inline_css
html = """"
<!doctype html>
<html lang="en">
<head>
<title>Charter 00144</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css"/>
</head>"""
print inline_css(html)
When certain HTML tags are turned into self-closing versions (e.g. <title />
), GMail considers the entire HTML as invalid and will not display it.
method="html"
in the etree.tostring
call.I am using inlinestyler in one of my scripts. I got a new empty line each time I call my script, although I do not print anything. I found out that it happens when I use inline_css.
Why do we print here?:
https://github.com/dlanger/inlinestyler/blob/master/inlinestyler/converter.py#L41
I'm using some background-size styles and inliner spawns some sentry logs about it as this property isn't in the CSV file. Looking at https://www.campaignmonitor.com/css/ this and some other CSS3 tags are supported by something. Would be nice to expand the table of known CSS properties.
Hi,
I have been getting the following error:
IOError: Too many open files: '/usr/local/lib/python2.7/dist-packages/inlinestyler/css_compliance.csv'
I was running this in a loop (5000+) and that's when this happened.
Does this module currently support Python3?
It would be good to update the supported platforms list on the PyPi record so it's explicit if there's support there. Will be testing this out soon in any case, so will update this ticket if it's not known.
I'm getting this fetching a css from anazon cloudfront
44 venv/local/lib/python2.7/site-packages/inlinestyler/converter.py in perform
raise IOError('The stylesheet ' + element.get("href") + ' could not be found') ...
If I curl the url causing the issue straight from the machine everything is fine.
Even with openssl:
openssl s_client -connect d1q7usoul9xakv.cloudfront.net:443 -CApath /etc/ssl/certs/
Start Time: 144489408
Timeout : 300 (sec)
Verify return code: 0 (ok)
I fixed the issue with a hack, but I don't think is perfect:
In converter.py
Before
css_content = requests.get(csspath).text
After:
css_content = requests.get(csspath, verify=False).text
Can you please let me know if there is a better way to sort out this issue?
When updating lxml > 5
I've got AttributeError
exception:
'CSSSelector' object has no attribute 'evaluate'
matching = CSSRelSelector.evaluate(document)
in this line: https://github.com/dlanger/inlinestyler/blob/master/inlinestyler/converter.py#L30
having a css like:
display: none !important;
will not add a style="display: none !important;"
attribute to elements.
The !imporant
part is omitted.
But it is useful: https://stackoverflow.com/questions/4013670/gmail-is-ignoring-displaynone
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.