Hi there - I came across switch via c.l.python and have been looking at it for preprocessing my CSS file. I've hit a problem - a parsing bug I think but I thought I'd raise it here:
My .CSS contains a definition like this:
margin:50px 0 10px 0;
padding:13px 0 5px 20px;
height:14px; /* the correct height */
and switch barfs on this:
Traceback (most recent call last):
File "switch.py", line 148, in ?
switch_output = parseFile(file_to_parse)
File "switch.py", line 27, in parseFile
stylesheet = StyleSheet.SSSStyleSheet( path )
File "/transfer/switch/StyleSheet.py", line 47, in __init__
if href: self._setHref(href)
File "/transfer/switch/StyleSheet.py", line 82, in _setHref
File "/transfer/switch/Object.py", line 103, in _parse
File "/transfer/switch/Translator.py", line 55, in array_pop
IndexError: pop from empty list
This seems to be due to the line:
which I appreciate is 'dodgy'; AFAIUI this and the following couple of lines comprise a hack to exploit the parsing in IE and get the line height right in all browsers. It would be great if Switch could parse this correctly!
I notice that there aren't many meaningful errors put out if switch encounters any problems; I understand that this is not an easy thing and for my purposes I was able to find the source of the problem using a binary chop. An addition to, say, print the line no. where an error was found would be good?
Thanks for your efforts
We developed Switch knowing that certain of the CSS hacks implemented by CSS developers would break the system.
Rather than build in what we felt are bad CSS habits, we didn't expressly allow *any* hacks, other than the small concession of the underscore hack(http://wellstyled.com/css-underscore-hack.html). In our experience, it's rarely necessary to use other hacks. The underscore trick and conditional HTML comments, both specifically targeting Internet Explorer, provide all the hackyness necessary.
Switch shouldn't barf, though. We'll fix that.
- Dave Worley
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.