Matthew Turland has posted a guide to compiling PHP with the Tidy extension (a tool to clean and repair HTML documents through direct manipulation).
I dug around a bit, but most resources I came across on Google were about using the tidy extension for PHP rather than doing a custom build of PHP that included the tidy extension. Once I figured the details out, I thought I'd share. They admittedly seemed somewhat obvious after the fact, though also were not communicated as explicitly as I would have liked anywhere that I could see.
TO use his method you'll need to have CVS working (either on a server or, like he did, a local machine) and be able to grab the latest PHP 5.3.x and tidy extension versions. When you do the compile for PHP, all you need to do is point it at the CVS checkout of tidy and you should be all set.