vuuvv / fizzler

Automatically exported from code.google.com/p/fizzler
GNU General Public License v3.0
0 stars 0 forks source link

Calculate the specificity of a given selector #39

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Would it be possible to calculate the specificity of a given selector based
on the W3 specification 

http://www.w3.org/TR/CSS2/cascade.html#specificity

There is a ruby project that does this and I think it would be a handy feature.

http://code.dunae.ca/css_parser/

CssParser.calculate_specificity('#content div p:first-line a:link') 
=> 114

My goal is to be able to take an html document and parse it applying all
the css styles inline on the actual elements. This is useful in getting
good email rendering results and I got the idea from premailer 

http://premailer.dialect.ca/

Original issue reported on code.google.com by jake....@gmail.com on 29 Oct 2009 at 1:28

GoogleCodeExporter commented 8 years ago
There is also a awesome css parser that I found on code project
http://www.codeproject.com/KB/recipes/CSSParser.aspx

Original comment by jake....@gmail.com on 29 Oct 2009 at 1:32

GoogleCodeExporter commented 8 years ago
I'm looking at the implementation of CssParser.calculate_specificity and it's 
so 
dead simple that it would stand on its own fine without any help from Fizzler. 
The 
only downside is that this implementation assumes a valid selector syntax. I've 
attached a C# port with tests. 

The Fizzler way to address this, though slightly more involved, would be to 
write an 
ISelectorGenerator implementation that carries out the calculation. The upside 
here 
would be calculation over a validated syntax.

Thoughts?

Original comment by azizatif on 29 Oct 2009 at 11:50

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This issue has been migrated to:
https://github.com/atifaziz/Fizzler/issues/39
The conversation continues there.
DO NOT post any further comments to the issue tracker on Google Code as it is 
shutting down.
You can also just subscribe to the issue on GitHub to receive notifications of 
any further development.

Original comment by azizatif on 23 Aug 2015 at 1:34