Hello,
Since your question is interesting, I have quickly written a very small Perl script that extracts all properties from a given list of style sheets.
For this script I used the CSS parser Allen Day and Cal Henderson, which you can find on the Comprehensive Perl Archive Network (aka CPAN).
This script takes all properties from a list of style sheets and generates a JavaScript array, as I said in my previous mail.
Usage : perl
css2js.pl --help
Usage: perl
css2js.pl (--help | --stylesheets=<list of style sheets>)
Let's apply the script to BluePrint:perl css2js.pl --stylesheets='forms.css;grid.css;ie.css;print.css;reset.css;typography.css'
This will create a JavaScrip array that contains all properties defined in the style sheets.
# Total: 42
var cssProperties = new array('font-style','border-right-width','background','padding-right','border','margin','border-right','height','margin-top','border-left-width','margin-right','color','width','position','display','padding-left','float','border-width','content','overflow-x','margin-left','border-bottom','border-color','border-style','background-color','font-family','padding','font','visibility','overflow','white-space','line-height','padding-top','margin-bottom','border-collapse','text-align','border-spacing','font-size','font-weight','clear','text-decoration','vertical-align');
OK. We have a quick and easy way to retrieve all the CSS properties to remove.
The JavaScript code should be:
for (i=0; i<cssProperties.length; i++)
{ $('#item').css(cssProperties[i], '').find().css(cssProperties[i], ''); }
The code above should remove all CSS properties listed in the array, for the element designed by its ID "item", and for all its children. I did not test it, but this part of the work should be OK.
I join the Perl script to this email (
css2js.pl).
In order to use it, make sure to install the two following Perl modules:
Note: These modules can be installed automatically using the CPAN installer (cpan -i CSS and (cpan -i Getopt::Long).
Regards,
Denis
2011/3/29 johnw
<john....@gmail.com>
Denis, how would that clear something inherited from, say: