Skip to main content

Inlines external CSS into HTML elements.

Project description

Version:
0.1.7
Download:

http://pypi.python.org/pypi/inlinestyler/

Source:

http://github.com/dlanger/inlinestyler/

Keywords:

inline, HTML, CSS, email, preflight

inlinestyler is an easy way to locally inline CSS into an HTML email message.

Styling HTML email is a black 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 - is Premailer. 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.

inlinestyler takes (most) of the functionality of Premailer, and makes it available locally, accessible without having call a remote service.

To see what inline-styler can do, check out this demo.

History

Dave Cranwell wrote the original inline-styler single-app Django project, and (graciously) released it. inlinestyler is a refactor of that project into a free-standing package usable outside of Django.

Requirements

inlinestyler requires the following packages in order to run:

  • cssutils (which will be installed by pip)

  • lxml (which we assume you already have installed through your OS)

It also requires a css_complaiance.csv file, which indicates the compatibility of various email clients with certain CSS features. This is included with the package, but can be updated manually from Campaign Monitor’s spreadsheet.

Usage

from inlinestyler.utils import inline_css
message_inline_css = inline_css(message_external_css)

message_external_css must be a string containing the message to be inlined, with the CSS presented in the HTML as one of:

  • an absolute link <link rel="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 the css_compliance.csv file), but this number isn’t yet exposed.

Contributions

All development happens at github: http://github.com/dlanger/inlinestyler.

Contributions are always more than welcome. If you see something missing, add it in and send me a pull request.

License

This distribution is licensed under the New BSD License. Please see the LICENSE file for a full copy of the license text.

As far as I can tell, Dave Cranwell released the underlying inline-styler project into the public domain:

I’m […] releasing it to the public after many requests for the source.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inlinestyler-0.2.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inlinestyler-0.2.0.linux-x86_64.exe (79.6 kB view details)

Uploaded Source

File details

Details for the file inlinestyler-0.2.0.tar.gz.

File metadata

  • Download URL: inlinestyler-0.2.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for inlinestyler-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c2e8e2a5437e9e0dfd5d6d377eb3e6ee0b9a973836ea0ae437e65a1f31433091
MD5 2219fadc69ba09cdb89c5c8dac1485f4
BLAKE2b-256 6f61cff7d9422be68dd06edec86765d5267027d753dc7114df55b2e969ee66c3

See more details on using hashes here.

File details

Details for the file inlinestyler-0.2.0.linux-x86_64.exe.

File metadata

File hashes

Hashes for inlinestyler-0.2.0.linux-x86_64.exe
Algorithm Hash digest
SHA256 bd33633018472068394271070faa2ff74aa94cf60462de6599a0c56ad1b797c9
MD5 a0dcbd034718da0e350f083b339ba7a1
BLAKE2b-256 e85698aca2d8d3485460ace313c03f4cad693c0295a78366d250e8dd45e1607e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page