lib/sproutcore/cssmin.rb
# Do miscellaneous compression methods on the style
Do miscellaneous compression methods on the style
Do miscellaneous compression methods on the style
def do_misc(script)
      script = script.gsub(/([\s:]+)(0)(px|em|%|in|cm|mm|pc|pt|ex)/) do |match|
        match.gsub(/(px|em|%|in|cm|mm|pc|pt|ex)/,'')
      end
      script = script.gsub(':0 0 0 0;', ':0;')
      script = script.gsub(':0 0 0 0}', ':0}')
      script = script.gsub(':0 0 0;', ':0;')
      script = script.gsub(':0 0 0}', ':0}')
      script = script.gsub(':0 0}', ':0}')
      script = script.gsub(':0 0;', ':0;')
      script = script.gsub('background-position:0;', 'background-position:0 0;');
      script = script.gsub(/[:\s]0+\.(\d+)/) do |match|
        match.sub('0', '') 
      end
      script = script.gsub(/[;]+/, ';')
      script = script.gsub(';}', '}')
      script = script.gsub('background-color:', 'background:')
      script = script.gsub(/font-weight[\s]*:[\s]*normal[\s]*;/,'font-weight:400;')
      script = script.gsub(/font-weight[\s]*:[\s]*normal[\s]*\}/,'font-weight:400}')
      script = script.gsub(/font[\s]*:[\s]*normal[\s;\}]*/) do |match|
        match.sub('normal', '400')
      end
      script = script.gsub(/font-weight[\s]*:[\s]*bold[\s]*;/,'font-weight:700;')
      script = script.gsub(/font-weight[\s]*:[\s]*bold[\s]*\}/,'font-weight:700}')
      script = script.gsub(/font[\s]*:[\s]*bold[\s;\}]*/) do |match|
        match.sub('bold', '700')
      end
      script
    end
def do_misc ( script ) script = script . gsub ( / ([ \s :]+)(0)(px|em|%|in|cm|mm|pc|pt|ex) / ) do | match | match . gsub ( / (px|em|%|in|cm|mm|pc|pt|ex) / , '' ) end script = script . gsub ( ':0 0 0 0;' , ':0;' ) script = script . gsub ( ':0 0 0 0}' , ':0}' ) script = script . gsub ( ':0 0 0;' , ':0;' ) script = script . gsub ( ':0 0 0}' , ':0}' ) script = script . gsub ( ':0 0}' , ':0}' ) script = script . gsub ( ':0 0;' , ':0;' ) script = script . gsub ( 'background-position:0;' , 'background-position:0 0;' ) ; script = script . gsub ( / [: \s ]0+ \. ( \d +) / ) do | match | match . sub ( '0' , '' ) end script = script . gsub ( / [;]+ / , ';' ) script = script . gsub ( ';}' , '}' ) script = script . gsub ( 'background-color:' , 'background:' ) script = script . gsub ( / font-weight[ \s ]*:[ \s ]*normal[ \s ]*; / , 'font-weight:400;' ) script = script . gsub ( / font-weight[ \s ]*:[ \s ]*normal[ \s ]* \} / , 'font-weight:400}' ) script = script . gsub ( / font[ \s ]*:[ \s ]*normal[ \s ; \} ]* / ) do | match | match . sub ( 'normal' , '400' ) end script = script . gsub ( / font-weight[ \s ]*:[ \s ]*bold[ \s ]*; / , 'font-weight:700;' ) script = script . gsub ( / font-weight[ \s ]*:[ \s ]*bold[ \s ]* \} / , 'font-weight:700}' ) script = script . gsub ( / font[ \s ]*:[ \s ]*bold[ \s ; \} ]* / ) do | match | match . sub ( 'bold' , '700' ) end script end
Do miscellaneous compression methods on the style
Do miscellaneous compression methods on the style
# Replace 0(pt,px,em,%) with 0 but only when preceded by : or a white-space # Replace 0 0 0 0; with 0. # Replace background-position:0; with background-position:0 0; # Replace 0.6 to .6, but only when preceded by : or a white-space # only first '0' !! # Replace ;;;; with ; # Replace ;} with } # Replace background-color: with background: # Replace font-weight:normal; with 400, bold with 700
script
<not_specific>