Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to Convert External CSS to Inline CSS in Ruby? [closed]

I am messing around with GoogleDocs and it has very very primitive CSS support. If you upload an MSWord .doc or an HTML file and export it as HTML, all styles are applied inline. They have a style block in the html file, but when you upload the HTML file back to google docs, it doesn't apply any non-inline styles.

So I was thinking "maybe there's a ruby tool for this". Is there anything out there I could use to take some CSS and have it parse it into the HTML nodes, maybe some nokogiri plugin?

like image 644
Lance Avatar asked Feb 16 '10 11:02

Lance


People also ask

How do you add CSS inline CSS internal CSS external CSS?

There are three ways to add CSS to HTML. You can add inline CSS in a style attribute to style a single HTML element on the page. You can embed an internal stylesheet by adding CSS to the head section of your HTML doc. Or you can link to an external stylesheet that will contain all your CSS separate from your HTML.

Does external CSS override inline?

Answer: You cannot override inline CSS if it has ! important . It has higher precedence than the style in your external CSS file. , there's no way to override an inline !


2 Answers

Check out alexdunae's Premailer on GitHub: http://github.com/alexdunae/premailer

Never tried it by myself, just stumbled upon. Maybe it helps.

like image 100
slu Avatar answered Oct 11 '22 11:10

slu


MailStyle is another solution: http://github.com/purify/mail_style

Looks like it has easy rails integration (actionmailer, sass), but I'm not sure that's what you are/were looking for.

like image 32
tassock Avatar answered Oct 11 '22 10:10

tassock