[PLUG] Validating HTML, was [OT] Another Web-related Question

Paul Heinlein heinlein at madboa.com
Mon Oct 11 12:50:02 UTC 2004


On Mon, 11 Oct 2004, Randall Lucas wrote:

> No need always to go to the w3c validator.  HTMLTidy will do the 
> trick for you locally, along with optionally formatting the HTML 
> into nicely indented, readable form.  Plus, if you want to get all 
> advanced, you can do neat things with find or xargs, plus I think 
> even get vim or emacs to automatically run it for you.

Let me second Randall's recommendation. tidy is very cool:

   http://tidy.sourceforge.net/

It sits in the toolchain of my personal web site:

   DocBook XML -> xsltproc -> tidy -> XHTML

The one oddity is that tidy is a poor Makefile citizen because it can 
return either 0 or 1 as a success value. So instead of invoking tidy 
directly, I use a wrapper script:

   #!/bin/sh
   USAGE="usage: $(basename $0) infile outfile"
   INFILE=${1:?$USAGE}
   OUTFILE=${2:?$USAGE}

   /usr/bin/tidy -wrap 132 -quiet -utf8 -indent -o $OUTFILE $INFILE
   RETVAL=$?
   if test $RETVAL -lt 2; then
     exit 0
   else
     exit $RETVAL
   fi

It's such a great tool. I don't even consider posting pages to my web 
site that haven't been tidy-ed.

--Paul Heinlein <heinlein at madboa.com>




More information about the PLUG mailing list