see whatever…

jump to menu

October 21, 2007

cssutils 0.9.4a1

Filed under: CSS,cssutils — see @ 12:11 am

oops, this has been a lot of work… Originally I planned to add a few new features like MediaQueries in the new release but as Walter wanted to maybe add his tokenizer to the lib I actually rewrote the complete cssutils tokenizer and parser as well. I am not sure if it is faster or slower now but it should be more to the specs (optimizations may come later…).

The old tokenizer was really unwieldy and a bit of a mess. It gave a list of Token objects.

The new one actually just emits token tuples and is more or less a generator (there are some not very elegant things later in the parser which work around problems I had with generators (there is no “peek” method which would be very handy) but all in all this is a bit simpler).

The tokenizer itself uses the actual productions from the spec as regexes which is much shorter and easier to compare with the specs. There are a few special cases (the order of regexes or how incomplete stylesheets can still be “completed” by the tokenizer and not later by the parser). The parser also should able to chew more than to older one.

Only real problem was which spec to choose. It seems as CSS 3 is not final yet CSS2.1 should be used but there are some problems too. Just today I found the errata for CSS2.1, not many and I knew the @charset problem before. Still it seems the myriad of different specs in different stages (CSS 2.1, Errata, Selector, spec, DOM Level 2 CSS and stylesheets, CSSOM) plus the real world (browser) implementations and things I personally think should be in the lib (keeping CSS hacks or get access to multiple same named property values) made (and make) it really difficult to decide which to use and where to look. As I do not have too much time for this project (luckily I had a few days off so could do quite a lot actually) this makes it even more difficult.

Anyway, 0.9.4a1 is out and as the test cases grow (and validate) the release is hopefully not too bad. I guess if browsers take a few years to (almost) comply to the specs a lib like cssutils is not doing too bad. Ok I know, browsers need to display something too which cssutils does not even attempt but still there is hardly even a decent CSS editor out there (Aptana is probably the best I know of).

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress