Skip to content

Commit e94ee2b

Browse files
Fix #16
1 parent 94c47a5 commit e94ee2b

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

css-html-js-minify.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,31 @@ def _compile_props(props_text, grouped=False):
215215
groups.append(g_id)
216216
else:
217217
g_id += 1
218-
return final_props, groups
218+
return (final_props, groups)
219219

220220

221-
def _prioritify(line_buffer, pgs):
221+
def _prioritify(line_of_css, css_props_text_as_list):
222222
"""Return args priority, priority is integer and smaller means higher."""
223-
props, groups = pgs
224-
priority, group = 9999, 0
225-
for css_property in props:
226-
if line_buffer.find(css_property + ':') != -1:
227-
priority = props.index(css_property)
228-
group = groups[priority]
223+
sorted_css_properties, groups_by_alphabetic_order = css_props_text_as_list
224+
priority_integer, group_integer = 9999, 0
225+
for css_property in sorted_css_properties:
226+
if css_property.lower() == line_of_css.split(":")[0].lower().strip():
227+
priority_integer = sorted_css_properties.index(css_property)
228+
group_integer = groups_by_alphabetic_order[priority_integer]
229+
log.debug("Line of CSS: '{0}', Priority for Sorting: #{1}.".format(
230+
line_of_css[:80].strip(), priority_integer))
229231
break
230-
return priority, group
232+
return (priority_integer, group_integer)
231233

232234

233235
def _props_grouper(props, pgs):
234236
"""Return groups for properties."""
235237
if not props:
236238
return props
237-
props = sorted([
238-
_ if _.strip().endswith(";")
239-
and not _.strip().endswith("*/") and not _.strip().endswith("/*")
240-
else _.rstrip() + ";\n" for _ in props])
239+
#props = sorted([
240+
#_ if _.strip().endswith(";")
241+
#and not _.strip().endswith("*/") and not _.strip().endswith("/*")
242+
#else _.rstrip() + ";\n" for _ in props])
241243
props_pg = zip(map(lambda prop: _prioritify(prop, pgs), props), props)
242244
props_pg = sorted(props_pg, key=lambda item: item[0][1])
243245
props_by_groups = map(

0 commit comments

Comments
 (0)