Tidy is a fabulous tool that helps do the following:
- Format your HTML so that it is clear and easy to read
- Fix any basic errors you made in coding your HTML
- Add the DTD you need for your document
- Format your HTML to conform to a specific DTD
- Alert you to any errors in your HTML code that may cause problems with validation
Tidy is free from the W3C. You can read more about Tidy and download it (for a variety of operating systems) at http://www.w3.org/People/Raggett/tidy/.
When you run Tidy, you need to specify how you want Tidy to format your code. Having to list these specifications each time you run Tidy quickly becomes tiresome. Fortunately, you can put your specifications into an external file and tell Tidy to look at that file, which makes using Tidy a lot more convenient.
The fastest, easiest way to use Tidy is on the command line, which you can find on Windows, Linux, and Mac OS X. We will cover each operating system in turn, focusing on how to set up Tidy so that it uses an external configuration file.
Windows
- Create the directory. Open Windows Explorer and create a new directory called "tidy" at the base of your C: drive. On my computer, C: now looks like this:
- Download the configuration file. Download this configuration file by right-clicking on the following link and selecting Save Target As ... Save this file into C:\tidy as "tidy_config.txt": "tidy_config.txt"
- Download Tidy. Download Tidy for Windows by right-clicking on the following link and selecting Save Target As ... Save this file into C:\tidy as "tidy.zip". If you've already downloaded Tidy, please move tidy.exe into C:\\tidy. After downloading tidy.zip, you'll need to unzip it and then make sure that tidy.exe is in C:\\tidy. Tidy for Windows
- Create a batch file. Open a text editor like Notepad and type the following into it, exactly as I have it here:
C:\tidy\tidy.exe -config c:\tidy\config.txt %1
- Save the batch file. Save this file into C:\Windows as "tidy.bat"; if you are using Windows NT or Windows 2000, you will need to save the file into C:\WINNT as "tidy.bat". You must include the ".bat" at the end of the file name, or it will not work!
- Edit your configuration file. Open C:\tidyconfig.txt in a text editor like Notepad. Read through it - it will take you a while, because there is a lot of information there! Change the configuration file as appropriate. When you are happy with your configuration, close the file.
- Create an HTML file. Create a sample Web page & save it. If you don't have a special place on your hard drive that you use for Web pages, then create a directory called "web" at the base of your C: drive and save your sample Web page there. Close your HTML file in whatever program you used to create it.
- Open the command prompt. Go to your Start menu and choose Programs > MS-DOS Prompt. If you are using Windows 2000, you will need to go to Start > Programs > Accessories > Command Prompt.
- Find your HTML file. Navigate in the command prompt to the directory in which your HTML file is located. If you need help navigating in the command prompt window, then go to Start > Help and search for "MS-DOS prompt". Read the information there.
- Test Tidy. Once you are in the directory that holds your HTML file, type the following at the command prompt (instead of filename.htm, use the name of your HTML file):
tidy filename.htm
You should see some information fly by in the window. When it stops, read the information. It tells you what changes were made to your file, and if there were any problems or concerns with the file.
- Look at your HTML file. Open the sample Web page you made in your text editor. Your code should have changed according to the changes you specified in your configuration file.
That's it - you now know how to use Tidy with a batch file, which will make using it far easier and more pleasant.
Linux
Mac OS X
Older version of Mac OS do not have a command line, so this tutorial will not cover that. If you're running an older version of Mac OS, you can download a GUI version of Tidy at http://www.geocities.com/terry_teague/tidy.html.
|