HTML Tidy options in PHP context

Posted on September 5th, 2010 by David Luhman and tagged .

<?php

// http://tidy.sourceforge.net/docs/quickref.html#add-xml-decl

$tidyOpts = array(
// 'bare' => TRUE, // strip MS HTML
// 'clean' => TRUE, // strip presentational tags
// 'css-prefix' => 'calc-', // CSS prefix for styles - default 'c'
// 'doctype' => 'omit', // DOCTYPE for output
// 'drop-empty-paras' => TRUE,
// 'drop-font-tags' => TRUE, // drop and with no corresponding style rules
// 'drop-proprietary-attributes' => TRUE, // drop things like MS data binding attributes
'wrap' => 0, // No wrapping initially
'word-2000' => TRUE,
'break-before-br' => TRUE, // should output a line break before each element.
'indent' => 'auto', // Indent the content of tags H1-H6, LI, TD, TD, or P
'indent-spaces' => 2,
);

$tidy = new tidy();
$tidy->parseFile('./myFile.html', $tidyOpts);
tidy_clean_repair($tidy);
echo $tidy;

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options