{"id":610,"date":"2007-05-22T22:32:55","date_gmt":"2007-05-22T20:32:55","guid":{"rendered":"http:\/\/planetozh.com\/blog\/2007\/05\/one-click-css-tidy-cleaning\/"},"modified":"2007-05-22T22:32:55","modified_gmt":"2007-05-22T20:32:55","slug":"one-click-css-tidy-cleaning","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2007\/05\/one-click-css-tidy-cleaning\/","title":{"rendered":"One-Click CSS Tidy Cleaning"},"content":{"rendered":"<p>I&#39;ve been using <a href=\"http:\/\/csstidy.sourceforge.net\/\">CSSTidy<\/a> lately, and I like it a lot. This is a pretty cool software that optimizes CSS files so that they are smaller and cleaner. It comes with a bunch of options and is available in Linux, OSX and Windows flavors.<\/p>\n<p><img src='http:\/\/planetozh.com\/blog\/wp-content\/uploads\/2007\/05\/csstidy_context_menu.gif' alt='CSSTidy context menu' class=\"imgcenter\" \/> I&#39;m running Windows on my test computer, and I made a convenient right click context menu on CSS files so I can clean them in one click. Here&#39;s how I did it:<br \/>\n<!--more--><\/p>\n<ol>\n<li>Download <a href=\"http:\/\/csstidy.sourceforge.net\/\">CSSTidy<\/a> of course, and put the executable file <em>csstidy.exe<\/em> in, say, <em>d:\\utils\\csstidy\\<\/em><\/li>\n<li>Create the following file <strong>csstidy.bat<\/strong> in the same directory :\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">@echo off<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">if &quot;%1&quot;==&quot;&quot; goto notok<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">copy %1 %~d1%~p1%~n1.orig%~x1<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">d:\\utils\\csstidy\\csstidy.exe %1 --preserve_css=false --remove_bslash=false --compress_colors=true --lowercase_s=true --timestamp=false --remove_last_;=true --compress_font-weight=true --allow_html_in_templates=false --silent=false --case_properties=1 --sort_properties=false --merge_selectors=0 --sort_selectors=false --template=default %1<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">goto end<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">:notok<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">echo Missing parameter: no filename !<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">pause<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp;<\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">:end<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>This bat file is a wrapper that will first backup your myfile.css to myfile.orig.css, then call csstidy.exe with pretty standard options: remove comments, remove indents, keep the file readable, etc&#8230;<\/li>\n<li>Now let&#39;s add the neato context menu to .css files :\n<ul>\n<li>Open the Control Panel and choose Folder Options. Select the &#39;File Types&#39; tab, and look for the &#39;CSS&#39; item. Click on &#39;Advanced&#39;, then click on &#39;New\u00e2\u20ac\u00a6&#39;<\/li>\n<li>In &#39;Action&#39;, type &#39;CSSTidy&#39;, and in &#39;Application used to perform action&#39;, enter the following command:\n<div id=\"ig-sh-2\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">code<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"code\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">d:\\utils\\csstidy\\csstidy.bat &quot;%1&quot;<\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<\/li>\n<\/li>\n<\/ol>\n<p>You&#39;re done ! It even works the same if you select multiple CSS files, right-click and pick CSSTidy in the context menu. Of course, remember to change the paths to reflect your own installation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve been using CSSTidy lately, and I like it a lot. This is a pretty cool software that optimizes CSS files so that they are smaller and cleaner. It comes with a bunch of options and is available in Linux, OSX and Windows flavors. I&#39;m running Windows on my test computer, and I made a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[2,55,207,4],"class_list":["post-610","post","type-post","status-publish","format-standard","hentry","tag-code","tag-css","tag-csstidy","tag-windows"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=610"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/610\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}