Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Tidy up your HTML with ... tidy! UNIX
I was messing around in the /usr/bin folder and found a binary called tidy, which is installed by default on OS X. Immediately curious, I looked up the function of this program. Its purpose is to generate cleaned-up versions of HTML, XML, and XHTML files, and it can even convert them. This is useful if you code web pages by hand, as I do. It fixes your mistakes, like the following, and many more:
<h1>heading
<h2>subheading</h3>
tidy will tell you the errors and then spit out a fixed version, which you can optionally save to a new file. Here are some examples: Convert HTML to well-formed XML and output to a new file (hit control-D after the output is finished):
tidy -asxml test.html -output fixed.xml
Just show the errors and quit:
tidy -errors test.html
Use upper case tags for output:
tidy -upper test.html
For more options, try man tidy or tidy -h. One use for tidy I can think of is cleaning up those horribly formatted Word webpages. tidy doesn't seem to like them either, but with the use of a configuration file and the word-2000 option, it cleans it up pretty nicely. A simple script could be written to feed a Word webpage through tidy, and then strip out the extra annoyances. See this page for more details.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[12,256 views]  

Tidy up your HTML with ... tidy! | 5 comments | Create New Account
Click here to return to the 'Tidy up your HTML with ... tidy!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Tidy up your HTML with ... tidy!
Authored by: wgscott on May 23, '06 07:45:26AM

Also check out

http://www.pixelfreak.net/tidy_service/



[ Reply to This | # ]
Tidy up your HTML with ... tidy!
Authored by: scottdb on May 23, '06 08:29:39AM

Both TextMate and BBEdit give you the ability to "Tidy" your HTML from within the application.

I bet someone has also made a Services thingy that also does this.



[ Reply to This | # ]
Tidy up your HTML with ... tidy!
Authored by: scottdb on May 23, '06 08:31:17AM

Both TextMate and BBEdit give you the ability to "Tidy" your HTML from within the application.

I bet someone has also made a Services thingy that also does this.

*oh wait* that's what the previous comment says...



[ Reply to This | # ]
Tidy up your HTML with ... tidy!
Authored by: Pedro Estarque on May 23, '06 09:04:29AM

Tidy is only installed by default on 10.4 onwards. I didn't noticed that since I've been compiling it for a long time. Nice to see apple shipping more an more standard unix utils.



[ Reply to This | # ]
Tidy up your HTML with ... tidy!
Authored by: feaverish on May 23, '06 12:33:17PM
skEdit also uses Tidy. And there is a Firefox Extension and a Safari Plugin that use Tidy to check the validity of web pages you visit. (The Firefox Extension can even clean up the code on any page.)

[ Reply to This | # ]