Merge tag '0.9.5' into debian/victoria
v0.9.5
Thomas Goirand
3 years ago
28 | 28 |
Compatibility
|
29 | 29 |
=============
|
30 | 30 |
|
31 | |
Tested under Python 2.6, 2.7 and 3.3
|
|
31 |
Tested under Python 2.7 and 3.3+
|
32 | 32 |
|
33 | 33 |
|
34 | 34 |
Installation
|
112 | 112 |
max_idx = len(css) - 1
|
113 | 113 |
append_idx = 0
|
114 | 114 |
sb = []
|
|
115 |
nest_term = None
|
115 | 116 |
|
116 | 117 |
for match in regexp.finditer(css):
|
117 | 118 |
name = match.group(1)
|
|
120 | 121 |
term = match.group(2) if match.lastindex > 1 else None
|
121 | 122 |
if not term:
|
122 | 123 |
term = ')'
|
|
124 |
nest_term = '('
|
123 | 125 |
|
124 | 126 |
found_term = False
|
125 | 127 |
end_idx = match.end(0) - 1
|
|
128 |
nest_idx = end_idx if nest_term else 0
|
|
129 |
nested = False
|
126 | 130 |
while not found_term and (end_idx + 1) <= max_idx:
|
|
131 |
if nest_term:
|
|
132 |
nest_idx = css.find(nest_term, nest_idx + 1)
|
127 | 133 |
end_idx = css.find(term, end_idx + 1)
|
128 | 134 |
|
129 | 135 |
if end_idx > 0:
|
|
136 |
if nest_idx > 0 and nest_idx < end_idx and \
|
|
137 |
css[nest_idx - 1] != '\\':
|
|
138 |
nested = True
|
|
139 |
|
130 | 140 |
if css[end_idx - 1] != '\\':
|
131 | |
found_term = True
|
132 | |
if term != ')':
|
133 | |
end_idx = css.find(')', end_idx)
|
|
141 |
if nested:
|
|
142 |
nested = False
|
|
143 |
else:
|
|
144 |
found_term = True
|
|
145 |
if term != ')':
|
|
146 |
end_idx = css.find(')', end_idx)
|
134 | 147 |
else:
|
135 | 148 |
raise ValueError('malformed css')
|
136 | 149 |
|
|
138 | 151 |
|
139 | 152 |
assert found_term
|
140 | 153 |
|
141 | |
token = css[start_idx:end_idx]
|
|
154 |
token = css[start_idx:end_idx].strip()
|
142 | 155 |
|
143 | 156 |
if remove_ws:
|
144 | 157 |
token = _ws_re.sub('', token)
|
51 | 51 |
a {content: calc(10px-10%}
|
52 | 52 |
'''
|
53 | 53 |
self.assertRaises(ValueError, compress, input)
|
|
54 |
|
|
55 |
def test_nested_1(self):
|
|
56 |
input = '''
|
|
57 |
a { width: calc( (10vh - 100px) / 4 + 30px ) }
|
|
58 |
'''
|
|
59 |
output = compress(input)
|
|
60 |
assert output == "a{width:calc((10vh - 100px) / 4 + 30px)}"
|
|
61 |
|
|
62 |
def test_nested_2(self):
|
|
63 |
input = '''
|
|
64 |
a { width: calc( ((10vh - 100px) / 4 + 30px ) }
|
|
65 |
'''
|
|
66 |
self.assertRaises(ValueError, compress, input)
|
17 | 17 |
|
18 | 18 |
setup(
|
19 | 19 |
name='csscompressor',
|
20 | |
version='0.9.4',
|
|
20 |
version='0.9.5',
|
21 | 21 |
url='http://github.com/sprymix/csscompressor',
|
22 | 22 |
license='BSD',
|
23 | 23 |
author='Yury Selivanov',
|