Cleaning an html fragment (OO support seems to half-arsed for now)
This will ensure all tags are closed, without adding any html/head/body tags around it.
<?php
$tidy_config = array(
'clean' => true,
'output-xhtml' => true,
'show-body-only' => true,
'wrap' => 0,
);
$tidy = tidy_parse_string($html_fragment, $tidy_config, 'UTF8');
$tidy->cleanRepair();
echo $tidy;
?>
Exemples
Ce simple exemple montre l'utilisation de base de Tidy.
Exemple #1 Utilisation de base de Tidy
<?php
ob_start();
?>
<html>un document HTML</html>
<?php
$html = ob_get_clean();
// Configuration
$config = array(
'indent' => true,
'output-xhtml' => true,
'wrap' => 200);
// Tidy
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
// Affichage
echo $tidy;
?>
Exemples
Brad
03-Mar-2009 08:50
03-Mar-2009 08:50
