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,189
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,321
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:22 PM   #5
Kelvyn
Staff
 
Kelvyn's Avatar
 
Join Date: Feb 2005
Location: In the Heart of the English Lake District
Posts: 1,381
Default

TopStyle Pro 3.11 has a default stylesweeper which removes capitals, places decalarations on individual lines and places selectors in alphabetical order. It also replaces colour names with the appropriate hex code, lines up the indenting - and probably other things I have not noticed.

I don't know if this is present also in TopStyle Lite.

   
__________________
Kelvyn

Web site design, hosting and marketing, Keswick in the UK Lake District

If you are planning a visit to Keswick then try Keswick Tourist Information website

Kelvyn is offline   Reply With Quote
Old 03-13-2006, 12:43 PM   #6
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,189
Default

Quote:
Originally Posted by dthomsen8
Now, who knows how to enter a carriage return (antique term, that!) in Metapad?
Can you copy and paste into the find or replace window? If so, copy a couple of chars at the end of a paragraph continuing to the beginning of the next, and paste them in, then delete the regular characters. What’s left would be the CR symbol.

If it doesn’t actually appear, you may still be able to replace with it. But there probably will be some sort of symbol.

   
__________________
[SIZE=2][COLOR=LemonChiffon]::[/COLOR][/SIZE]
[SIGPIC][/SIGPIC]
ktinkel is offline   Reply With Quote
Old 03-13-2006, 12:56 PM   #7
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   #8
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, 01:33 AM   #9
LoisWakeman
Staff
 
LoisWakeman's Avatar
 
Join Date: Jan 2005
Location: Uplyme, Devon, England
Posts: 1,402
Default

It isn't....
LoisWakeman is offline   Reply With Quote
Old 03-14-2006, 04:48 AM   #10
dthomsen8
Member
 
dthomsen8's Avatar
 
Join Date: Aug 2005
Location: Philadelphia, PA 19130
Posts: 2,158
Default Price of TopStyle Pro

Quote:
Originally Posted by Kelvyn
TopStyle Pro 3.11 has a default stylesweeper which removes capitals, places decalarations on individual lines and places selectors in alphabetical order. It also replaces colour names with the appropriate hex code, lines up the indenting - and probably other things I have not noticed.

I don't know if this is present also in TopStyle Lite.
Their web site says TopStyle Pro is $79.95. For that amount, I will do it by hand.
dthomsen8 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 10:22 PM.


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