Package: inlinestyler
Version:0.2.4Download:http://pypi.python.org/pypi/inlinestyler/Source:http://github.com/dlanger/inlinestyler/Keywords:inline, HTML, CSS, email, preflightinlinestyleris an easy way to locally inline CSS into an HTML email message.Styling HTML email is ablack art. CSS works, but only when it’s been placed
inline on the individual elements (and event then, not always) - which makes
development frustrating, and iteration slow.The general solution is to use an inlining service, which takes a message with
the CSS placed externally, and rewrites it so that all CSS is applied to the
individual elements. The most widely used of these services - and as far as I
can tell, the one that powers CampaignMonitor - isPremailer. It’s a great
service, and the guys behind it put a lot of work into keeping it up to date
with the most recent discoveries in what works and what doesn’t.inlinestylertakes (most) of the functionality of Premailer, and makes it
available locally, accessible without having call a remote service.To see whatinline-stylercan do, check out thisdemo.Caveat EmptorThis project is relatively unmaintained. I will continue to do simple bugfixes
(and patches with tests are welcome), but I won’t be adding features or making
new CSS attributes work.If this doesn’t do what you need, check out thepremailer project.HistoryDave Cranwellwrote the originalinline-stylersingle-app Django project.inlinestyleris a refactor of that project into a free-standing package usable
outside of Django.Requirementsinlinestylerrequires the following packages in order to run:cssutilslxmlIt also requires acss_complaiance.csvfile, which indicates the
compatibility of various email clients with certain CSS features. This
is included with the package, but can be updated manually fromCampaign Monitor’s spreadsheet.Usagefrom inlinestyler.utils import inline_css
message_inline_css = inline_css(message_external_css)message_external_cssmust be a string containing the message to be inlined,
with the CSS presented in the HTML as one of:an absolute link<linkrel="stylesheet"href="http://mysite.com/styles.css"/>a<style>block in the<head>, without the use of@import.The code will also calculate an estimate for how compatible your message is with
various clients (using thecss_compliance.csvfile), but this number isn’t
yet exposed.ContributionsAll development happens at github:http://github.com/dlanger/inlinestyler.To get yourself started:Clone this repo somewheremake initto install the right dependenciesmake testto run the test suiteContributions are always more than welcome. If you see something missing, add it
in and send me a pull request.NOTE: Ubuntu 12.04 (and some other distros) includelibxsltversion1.1.26, which changes the now-empty<head>tag to<head/>- which
isn’t valid HTML 5. To see which version oflibxsltwas used to build
yourlibxml, examine the output ofmake initand look for the
line that looks likeUsing build configuration of libxslt 1.1.XX; if
that says26, some test failures are expected (at which point, you
can rely onTravisCIto run your tests for you).You could also install your own version oflibxsltfrom source, but
you’re probably going to have a bad time.LicenseThis distribution is licensed under theNew BSD License. Please see theLICENSEfile for a full copy of the license text.As far as I can tell, Dave Cranwellreleasedthe underlyinginline-stylerproject into the public domain:I’m […] releasing it to the public after many requests for the source.