[lxml-dev] cssselect and cssutils
Ian Bicking
ianb at colorstudy.com
Mon Jan 7 17:55:42 CET 2008
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 at colorstudy.com : http://blog.ianbicking.org
More information about the lxml-dev
mailing list