[lxml-dev] cssselect and cssutils

Hi Christof, Höke, Christof wrote:
You are the main developer for lxml, right?
Yep, but not the only one. :)
I was trying the CSSSelect facility for a Python CSS library I am developing (http://code.google.com/p/cssutils/)
Cool. I knew about cssutils, felt that its field of application was related to cssselect (and lxml in general) but not with too much of an overlap - and always thought it would be nice to have it working with lxml in some way.
and I think there are some minor problems with "*" or "*|*" (I need to check again and I'll put them on the bug tracker then) but a question regarding support for pseudo selectors: Would it be possible to support stuff like :first-letter (currently not working is it not?) with Python XPath extension functions which should be able to do what XPath cannot? Are you maybe even working on it? I guess things like :first-line are problematic but other should be ok.
I'm not the primary person to ask here. cssselect was developed by Ian Bicking, he knows best what works, what doesn't, and how to fix it. :)
If I get the time I would try some things out and report back, this was just an idea that I had while playing with CSSSelector...
Go ahead, this is open source. Any help, testing and ideas are always appreciated.
Lxml is really great stuff BTW, it was actually quite simple using lxml and a CSSStyleSheet on a given HTML. (Not released yet but an example is in the SVN).
Great. In case there's anything we can do on lxml's side, please ask on the list.
Also the XPath extension facility is really great, I used Pyana until some time ago but now use lxml for most projects.
Competition is best when you win. :) Stefan

Stefan Behnel wrote:
Hi Christof,
Höke, Christof wrote:
You are the main developer for lxml, right?
Yep, but not the only one. :)
I was trying the CSSSelect facility for a Python CSS library I am developing (http://code.google.com/p/cssutils/)
Cool. I knew about cssutils, felt that its field of application was related to cssselect (and lxml in general) but not with too much of an overlap - and always thought it would be nice to have it working with lxml in some way.
Yeah, it would be cool to be able to take a stylesheet and turn it into style tags, to make the HTML relocatable without losing the style. That's just one idea that has occurred to me in the past.
and I think there are some minor problems with "*" or "*|*" (I need to check again and I'll put them on the bug tracker then) but a question regarding support for pseudo selectors: Would it be possible to support stuff like :first-letter (currently not working is it not?) with Python XPath extension functions which should be able to do what XPath cannot? Are you maybe even working on it? I guess things like :first-line are problematic but other should be ok.
::first-letter is hard because it doesn't match any object in lxml. If it returned a string like "A" it would be very much out of context (e.g., no parent pointer), and it would be hard to do anything useful with it. To make it useful I think it would require some new stringish object that also looked nodeish (e.g., had a .getparent() method). Though maybe an object like that should exist; something similar would be needed for representing ranges. ::first-line, of course, depends on a rendering, so it's right out. I haven't been doing any work on selectors recently. There are a couple places where * doesn't work properly (and fixing it would probably require a Python XPath function), though they should give an exception. If not, then it's a bug of some sort. -- Ian Bicking : ianb@colorstudy.com : http://blog.ianbicking.org
participants (2)
-
Ian Bicking
-
Stefan Behnel