I'm doing some web-dev and the designers slice and export from photoshop. The generated code is horrendous. The first thing i'm doing is taking everything out of the tags and putting them in css files. So i was wondering if there was a tool that can automate this?
I would write my own script, here You can take some inspiration:
This does the opposite, but if You like Ruby, may be You can study the code: search for premailer on github, It use the Hpricot gem.
Of course, if don't want to spend time coding You can use tidy:
tidy -clean your-crap-inlined-file.html
If you your-crap-inlined-file.html contain: <p style="color:red;"> Some TEXT ...</p>
It will replace It inserting something like this
<style type="text/css">
/*<![CDATA[*/
p.c1 {color:red;}
/*]]>*/
</style>
on top of your file and at the same time It replace your inline code with:
<p class="c1">Some TEXT ...</p>
HTML Tidy is a great tool. It won't do what you want exactly, but it may be a good start if you are using generated html. Here is an online instance: http://infohound.net/tidy/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With