PHP Doku:: Beispiele - tidy.examples.html

Verlauf / Chronik / History: (5) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenTidyBeispiele

Ein Service von Reinhard Neidl - Webprogrammierung.

Tidy

<<Vordefinierte Konstanten

Beispiele>>


UnterSeiten:

Beispiele

Inhaltsverzeichnis


3 BenutzerBeiträge:
- Beiträge aktualisieren...
Dmitri Snytkine cms.lampcms.com
23.12.2009 23:26
Important notice about configuration options:
If you read the quickref on this page:
http://tidy.sourceforge.net/docs/quickref.html
you may get an idea that the boolean values for config options can be set as 'y' or 'yes' or 'n' or 'no'
but that's not true for the tidy extension in php.

Boolean values MUST be set only as true or false (without quotes or cause), otherwise tidy just ignores your configuration. It will not raise any error or warning but will just ignore your 'yes' or 'no' values.

For example, this config array will not have the desired effect:
<?php $config = array('drop-proprietary-attributes' => 'yes'); ?>

You must set option to true:
<?php $config = array('drop-proprietary-attributes' => true); ?>
nicolas [at] adaka [dot] fr
25.11.2008 10:33
That seems to be the correct config to symply tidy an HTML fragment (in a valid XHTML syntax) :

<?php
    $tidy_config   
=    array(
       
'clean'                            =>    true,
       
'drop-proprietary-attributes'    =>    true,
       
'output-xhtml'                    =>    true,
       
'show-body-only'                =>    true,
       
'word-2000'                        =>    true,
       
'wrap'                            =>    '0'
   
);
?>
dan [@t] authenticdesign [d_o_t] net
22.08.2008 19:44
If you're just looking for a quick and dirty way to output HTML code you created in a formatted way use this technique...

<?php
$html
= 'a chunk of html you created';
$config = array(
           
'indent'         => true,
           
'output-xml'     => true,
           
'input-xml'     => true,
           
'wrap'         => '1000');

// Tidy
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
echo
tidy_get_output($tidy);
?>

... This seemed to get the result I wanted every time.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)