Here's what I'm giving it:
Code: Select all
$mystring = '<h1><a name="anchor_id"></a>Anchor Text</h1>';
$tidy = new tidy;
$tidy_config = Array(
'indent' => true,
'output-xhtml' => true,
'anchor-as-name' => no,
'drop-empty-paras' => true,
'logical-emphasis' => true,
'quote-ampersand' => true,
'preserve-entities' => true,
'wrap' => 0,
'char-encoding' => 'utf8',
'vertical-space' => true,
'indent' => false,
'break-before-br' => true,
'lower-literals' => true,
'show-body-only' => true,
'output-xhtml' => true
);
$tidy->parseString($mystring,$tidy_config,'utf8');
$tidy->cleanRepair();
$clean_html = $tidy;
Code: Select all
<h1><a name="anchor_id"></a>Anchor Text</h1>Code: Select all
<h1><a id="anchor_id"></a>Anchor Text</h1>Code: Select all
<h1><a name="anchor_id" id="anchor_id"></a>Anchor Text</h1>I have horrible HTML (Word-generated) going in, so I have to run Tidy on it--my final product has to be W3C-valid and I have to parse the equivalent of 250-300 8.5" x 11" pages of formatted text every day that I didn't generate myself (I would have written the silly things in HTML to begin with!).
Any idea what I'm doing wrong? I thought by setting anchor-as-name to false (I've tried values of false, no, 0) that it would convert it to id and eliminate "name" entirely. :-/