# Tidy and B3

- Thread: https://externals.io/message/6438
- Original archive: https://news-web.php.net/php.internals/6438
- Started by John Coggeshall on 2003-12-14T06:10:10+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6438 — John Coggeshall — 2003-12-14T06:10:10+00:00

URL: https://externals.io/message/6438#6438

In response to the suggestions of Thies and others, I went back through
tidy and made a number of improvements to the API that I think should
make most people happy and make tidy ready for B3. Notable changes are:

Multiple Document Processing

	$a = tidy_parse_file("http://www.php.net/");
	tidy_clean_repair($a);
	echo tidy_get_output($a);

Dual-Nature Object and object overloading:

	$a = tidy_parse_file("http://www.php.net/");
	$a->clean_repair();
	echo $a;
	echo $a->error_buf;

	/* or... */
	
	$a = new tidy_doc();
	$a->clean_repair();

	/* Of course, you can also cross-use the syntax */

	$a = new tidy_doc();
	tidy_clean_repair($a);
	echo $a;

A bit cleaner parsing ability:

	/* Get the Body node object */
	$body = $a->body();
	/* Get the 'BGCOLOR' attribute of the node */
	echo $body->attribute['bgcolor'];
	/* echo everything from <body>....</body> */
	echo $body;

	/* Check to see if there is any content of the
	body by looking for a child node. If there is,
	echo only the content of the body... */

	if($body->has_children()) {
		echo $body->child[0]; 	/* Another node */
	}

You can also specify a default tidy configuration setup by setting
tidy.default_config to a default configuration file, and automatically
have tidy clean/repair the output by setting tidy.clean_output to true. 

I think with these changes tidy is ready to be packaged in B3, since no
one really opposed it before can we get this done ASAP? If you'd like to
play with tidy yourself, I have committed my work to HEAD in pecl/tidy

John


-- 
-=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=-
John Coggeshall                   http://www.coggeshall.org/
The PHP Developer's Handbook    http://www.php-handbook.com/
-=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=
