隨筆-167  評論-65  文章-0  trackbacks-0
          在網上下載了css,經常是被壓縮過的,急需要轉化一下,如果你是用的linux,你可以用awk command line來解決:

          $ cat somefile.css | awk '{gsub(/{|}|;/,"&\n"); print}' >> uncompressed.css

          后來個人用ruby寫了個轉化的代碼:

          輸出到控制臺:
          path = '/home/feng/compress.css'
          string = File.read(path)
          puts string.gsub!(/;/,";\n").gsub!(/\}/,"\n}\n").gsub!(/\{/,"\n{\n")


          輸出到文件:
          path = '/home/feng/compress.css'
          file = File.new(path, "r")
          path1 = '/home/feng/uncompress.css'
          File.open(path1, "wb") do   |f|
            f.write(file.readline().gsub!(/;/,";\n").gsub!(/\}/,"\n}\n").gsub!(/\{/,"\n{\n"))
          end


          ref:
          http://www.commandlinefu.com/commands/view/2339/uncompress-a-css-file




          write by feng
          posted on 2009-06-30 18:27 fl1429 閱讀(220) 評論(0)  編輯  收藏 所屬分類: Rails
          已訪問數:
          free counters
          主站蜘蛛池模板: 黄梅县| 通道| 囊谦县| 南江县| 张家川| 徐水县| 西青区| 伊川县| 安仁县| 陇南市| 和田市| 承德县| 新民市| 伊川县| 凤阳县| 梓潼县| 沧源| 长泰县| 克东县| 广宗县| 霸州市| 阿克苏市| 安西县| 光山县| 高雄县| 扶绥县| 建德市| 申扎县| 响水县| 麟游县| 白城市| 嘉鱼县| 阜城县| 蒙城县| 甘肃省| 新河县| 长治县| 濉溪县| 双牌县| 河池市| 新田县|