note 47638 deleted from function.tidy-construct by nlopess
| From: | nlopess@php.net | Date: | Tue, 23 Nov 2004 18:08:25 +0000 |
| Subject: | note 47638 deleted from function.tidy-construct by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80937@lists.php.net to get a copy of this message | ||
Note Submitter: csnyder of the chxo.com
----
The object-oriented approach to using tidy is woefully under-documented here, but a quick
get_class_methods( 'tidy' ) will tell you what methods are available.
On my PHP-5.0.2 system, I get the following list of methods:
cleanRepair
parseFile
parseString
repairString
repairFile
diagnose
getRelease
getConfig
getStatus
getHtmlVer
isXhtml
isXml
root
head
html
body
__construct
This implies that an example of tidy usage might be:
<?php
// $file is the path to the unclean document
// $clean is the tidy'ed document
$config = array( 'output-xhtml'=>TRUE,
'doctype'=>'loose',
'logical-emphasis'=>TRUE,
'enclose-block-text'=>TRUE,
'add-xml-space'=>TRUE,
'alt-text'=>'image'
);
$myTidy = new tidy( $file, $config );
$myTidy->cleanRepair();
$clean = $myTidy->root();
?>
Note that using purely OO tidy, you can't specify a custom configuration without loading the
document from a file, since the config array must be passed to the constructor, and the constructor
won't accept NULL for the filename parameter.