HTML tidy
November 22nd, 2003
Following on from my previous posting about perltidy. Here's an example of the output from perltidy. Note: this script is something I was working on a while ago – an online glossary – and I am not sure the version I've HTML-ised is the finished version. It's intended purely as an example of what perltidy does, not as an example of a working Perl script.
I have now found a program that will reformat your HTML. I should have found it first time of looking really, because it's a very close relative of perltidy.
HTML Tidy (originally written by Dave Raggett, now maintained by volunteers on SourceForge at:
http://tidy.sourceforge.net/
You can download a Windows executable at:
http://tidy.int64.org/
This is a command-line program – i.e. you open a console window (Start > Run > "cmd") and type in a command. For best results, put tidy.exe somewhere in your PATH (see What is your PATH?).
Tidy UI (a Windows graphical user interface for HTML Tidy, written by Charles Reitzel):
http://users.rcn.com/creitzel/tidy.html#tidyui
This is a very nice GUI version of HTML Tidy. You'll want to use this if you don't like working on the command line. From a brief test it seems to do the job and is very easy to use.
HTMLtrim:
http://sourceforge.net/projects/htmltrim
This is another GUI front end to HTML Tidy, but after one quick try-out I don't like it as much as tidyui, because it's not as Windowsy as tidyui and doesn't seem to offer much more than using the command line. By default it overwrites your original HTML file with a reformatted one. I'm sure this is one of the configuration options you can change, but I don't like overwriting the input file as default behaviour.
What is your PATH?
Your PATH is an environment variable that contains a list of directories. It tells Windows where to look for programs if they are not found in the current directory.
Adding directories to your PATH is useful because you can then type in the name of an executable file in one of those directories, while you are in some other directory, and the program will be found and executed. You don't need to qualify the program name with a path. Windows looks in the current directory and if it doesn't find the program, it looks for it in all the directories in your PATH.
How do I know what directories are in my PATH?
Open a console Window (by clicking Start > Run, typing cmd and clicking OK). Enter the command echo %PATH% and the contents of this environment variable are displayed.
How do I edit my PATH?
Open the Control Panel (by clicking Start > Settings > Control Panel) and double-click System. In the System Properties window, select the Advanced tab and click Environment Variables. In the Environment Variables dialog box, select Path in the System variables list and click Edit. In the Edit System Variable dialog box, edit the list of directories in the Variable value field, then click OK, then OK, then OK again.
The new PATH will be available the next time you open a console window. Note: if you had a console window open before changing your PATH, it won't know anything about the new PATH. You need to close the window and open a new one.
Potentially similar posts
- Rails Chronicles – Part 2 – July 2011
- Adding your choice of text editor to Flare’s Open With menu – December 2010
- Fix “No topics found” issue in CHM output – November 2010
- Perl basics for beginners (on Windows) – August 2010
- Gotchas with running a Perl script as a cron job – August 2010