How can I merge CSS definitions in files into inline style attributes, using Perl?
- by mintywalker
Many email clients don't like linked CSS stylesheets, or even the embedded <style> tag, but rather want the CSS to appear inline as style attributes on all your markup.
BAD: <link rel=stylesheet type="text/css" href="/style.css">
BAD: <style type="text/css">...</style>
WORKS: <h1 style="margin: 0">...</h1>
However this inline style attribute approach is a right pain to manage.
I've found tools for Ruby and PHP that will take a CSS file and some separate markup as input and return you the merged result - a single file of markup with all the CSS converted to style attributes.
I'm looking for a Perl solution to this problem, but I've not found one on CPAN or by searching Google. Any pointers? Alternatively, are there CPAN modules one could combine to achieve the same result?
Ruby http://code.dunae.ca/premailer.web/
PHP http://www.pelagodesign.com/sidecar/emogrifier/
Perl ?