DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Reply
 
Thread Tools Display Modes
Old 03-13-2006, 08:12 AM   #1
dthomsen8
Member
 
dthomsen8's Avatar
 
Join Date: Aug 2005
Location: Philadelphia, PA 19130
Posts: 2,158
Default TIDY for CSS?

Is there an equivalent of TIDY, a tool for cleaning up HTML, for CSS?

In particular, if I have a style sheet filled with capital letters, is there an easy way to get it changed to lower case, and better yet, change very long lines of code to lines with one specification per line?

I spent some time with GOOGLE on this question, but never found anything practical.

My own attempt to do it with Foxpro for DOS works fine in changing to lower case, but the result fails in actual use. I don't know why, but I suspect some subtle character or line ending problem.
dthomsen8 is offline   Reply With Quote
Old 03-13-2006, 08:44 AM   #2
ktinkel
Founding Sysop
 
ktinkel's Avatar
 
Join Date: Oct 2004
Location: In Connecticut, on the Housatonic River near its mouth at Long Island Sound.
Posts: 11,187
Default

Quote:
Originally Posted by dthomsen8
In particular, if I have a style sheet filled with capital letters, is there an easy way to get it changed to lower case, and better yet, change very long lines of code to lines with one specification per line?
I do those things using search-and-replace in a plain text editor.

Change case fixes the caps.

To divide up long lines of CSS properties, search for semicolon and replace it with [ ; CR ]. (In fact, I would replace it with [ ; CR Tab ] because I like to indent those lists.)

In my text editor, the CR would be [ \r ]. In Word it is [ ^p ]. Your software may follow a different convention, but it should be discoverable.

   
__________________
[SIZE=2][COLOR=LemonChiffon]::[/COLOR][/SIZE]
[SIGPIC][/SIGPIC]
ktinkel is offline   Reply With Quote
Old 03-13-2006, 10:13 AM   #3
dthomsen8
Member
 
dthomsen8's Avatar
 
Join Date: Aug 2005
Location: Philadelphia, PA 19130
Posts: 2,158
Default

KT:

Excellent answer, telling me most of what I want to know.

Now, who knows how to enter a carriage return (antique term, that!) in Metapad?
dthomsen8 is offline   Reply With Quote
Old 03-13-2006, 11:33 AM   #4
Bo Aakerstrom
Member
 
Bo Aakerstrom's Avatar
 
Join Date: Mar 2005
Location: Derby,UK
Posts: 1,433
Default

Aparently there is such an application: aptly named CSS Tidy!

I haven't tried it but looks like it could be useful. I have taken to using MP Sofware's PHP Editor to start both CSS and web pages off with and find it very handy as you can save snippets of code to be inserted in a document (a bit like using LEGO blocks). It doesn't clean up your exisiting style sheets though...
Bo Aakerstrom is offline   Reply With Quote
Old 03-13-2006, 12:56 PM   #5
dthomsen8
Member
 
dthomsen8's Avatar
 
Join Date: Aug 2005
Location: Philadelphia, PA 19130
Posts: 2,158
Default Online CSS Tidy

Quote:
Originally Posted by Bo Aakerstrom
Aparently there is such an application: aptly named CSS Tidy!

I haven't tried it but looks like it could be useful. I have taken to using MP Sofware's PHP Editor to start both CSS and web pages off with and find it very handy as you can save snippets of code to be inserted in a document (a bit like using LEGO blocks). It doesn't clean up your exisiting style sheets though...
I tried the online version, and I am not comfortable with some of the optimization. I don't think "0px" should become "0" or that color values should be shortened. I want to stay specific with those values.

Optimised number: Changed "1.0em" to "1em"
Optimised number: Changed "0px" to "0"
Optimised number: Changed "0px" to "0"
Optimised color: Changed "#000000" to "#000"
Optimised number: Changed "0%" to "0"
Optimised color: Changed "#666666" to "#666"
Optimised color: Changed "#000000" to "#000"
Optimised color: Changed "#ffffff" to "#fff"

Last edited by dthomsen8; 03-13-2006 at 12:58 PM. Reason: Formatting change list.
dthomsen8 is offline   Reply With Quote
Old 03-13-2006, 01:42 PM   #6
iamback
Member
 
iamback's Avatar
 
Join Date: Oct 2005
Location: Amsterdam, NL
Posts: 4,894
Default

Quote:
Originally Posted by dthomsen8
I tried the online version, and I am not comfortable with some of the optimization. I don't think "0px" should become "0" or that color values should be shortened. I want to stay specific with those values.
I certainly think all zero values should become just 0 and not 0px, 0em, 0pt, 0% or whatever (as mentioned before) - I see that as actually being more specific! As to shortening color values, that's a matter of style and preference; ideally whether or not to shorten those should be a configurable option.

I don't see anything wrong in the examples you give though. Could be a good trade-off to end up with more valid code (disregarding the things you don't like but are valid, but getting things that are not valid actually repaired) - though you're not giving us any example of that kind of behavior. Does it actually repair the real problems?

What about ordering of properties?

Edit: Actually, there are a load of options - look here; I don't see an option to not remove any comments though. Needs more work

   
__________________
Marjolein Katsma
Look through my eyes on Cultural Surfaces (soon!), My ArtFlakes shop and Flickr.
Occasionally I am also connecting online dots... and sometimes you can follow me on Marjolein's Travel Blog
iamback is offline   Reply With Quote
Old 03-14-2006, 04:53 AM   #7
dthomsen8
Member
 
dthomsen8's Avatar
 
Join Date: Aug 2005
Location: Philadelphia, PA 19130
Posts: 2,158
Default Zeros without units?

Quote:
Originally Posted by iamback
I certainly think all zero values should become just 0 and not 0px, 0em, 0pt, 0% or whatever (as mentioned before) - I see that as actually being more specific! As to shortening color values, that's a matter of style and preference; ideally whether or not to shorten those should be a configurable option.

Edit: Actually, there are a load of options - look here; I don't see an option to not remove any comments though. Needs more work
I believe I saw a thread about problems with zeros without units mixed with actual lengths, but I am not sure. Perhaps someone else knows.

I also would not like to lose my comments. I don't have others working with me, but I need reminders to myself in some cases. I will stick to the suggestion by Lois to use a text editor (Metapad for me) to get lower case.
dthomsen8 is offline   Reply With Quote
Old 03-14-2006, 06:16 AM   #8
iamback
Member
 
iamback's Avatar
 
Join Date: Oct 2005
Location: Amsterdam, NL
Posts: 4,894
Default

Quote:
Originally Posted by dthomsen8
I believe I saw a thread about problems with zeros without units mixed with actual lengths, but I am not sure.
Nope - just avoid mixing units in the same direction (especially horizontally), that's what we discussed; but zero is zero whatever the units - leaving off the units makes that explicit.

Quote:
Originally Posted by dthomsen8
I also would not like to lose my comments. I don't have others working with me, but I need reminders to myself in some cases.
Exactly! Comments are essential. The application seems more geared toward compressing CSS than toward tidying it - that's not bad not so bad if you do it dynamically on the server (to ensure faster downloads) but pretty useless for a copy you're developing or simply need to maintain.

   
__________________
Marjolein Katsma
Look through my eyes on Cultural Surfaces (soon!), My ArtFlakes shop and Flickr.
Occasionally I am also connecting online dots... and sometimes you can follow me on Marjolein's Travel Blog
iamback is offline   Reply With Quote
Old 03-27-2006, 10:54 AM   #9
dacoyle
Member
 
dacoyle's Avatar
 
Join Date: Aug 2005
Location: Arlington, VA (across the river from Washington, DC)
Posts: 560
Default

Quote:
Originally Posted by iamback
Exactly! Comments are essential. The application seems more geared toward compressing CSS than toward tidying it - that's not bad not so bad if you do it dynamically on the server (to ensure faster downloads) but pretty useless for a copy you're developing or simply need to maintain.
I spent a few hours last week adding comments to my work places' primary css. Only a few of us are allowed to edit the file, but with multiple developers it's essential to have the comments. Especially for some of the original styles, back in the "old days" when we weren't as good at naming styles.

   
__________________
Dennis
dacoyle is offline   Reply With Quote
Old 03-14-2006, 08:45 AM   #10
Michael Rowley
Member
 
Join Date: Jan 2005
Location: Ipswich (the one in England)
Posts: 5,105
Default

Dave:

zeros without units mixed with actual lengths

There is actually a difference: 0 em compared with 1 em just means 'nearer 0 em than 1 em' compared with 'nearer 1 em than 0 em or 2 em'; zero means 'nothing at all, not even the tiniest amount'.

   
__________________
Michael
Michael Rowley is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tidy Help CarlSeiler Web Site Building & Maintenance 11 02-26-2007 04:41 PM
Tidy dacoyle Web Site Building & Maintenance 9 11-25-2006 04:06 PM


All times are GMT -8. The time now is 06:44 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Contents copyright 2004–2019 Desktop Publishing Forum and its members.