2

I have gone through the docs but am not seeing how I can prevent tidy from stripping my PHP. My config is as follows:

anchor-as-name: no
doctype: omit
drop-empty-paras: no
fix-uri: no
literal-attributes: yes
merge-divs: no
merge-spans: no
numeric-entities: no
preserve-entities: yes
quote-ampersand: no
quote-marks: no
show-body-only: yes
indent: auto
indent-spaces: 4
tab-size: 4
wrap: 0
wrap-asp: no
wrap-jste: no
wrap-php: no
wrap-sections: no
tidy-mark: no
new-blocklevel-tags: article,aside,command,canvas,dialog,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,meter 
new-inline-tags: video,audio,canvas,ruby,rt,rp,time,meter,progress,datalist,keygen,mark,output,source,wbr
force-output: yes
quiet: yes
show-warnings: yes
3
  • maybe the php will save a cache html file, then tidy will clean that. Commented Sep 4, 2012 at 14:10
  • I'm not following. Can you clarify? Commented Sep 4, 2012 at 18:30
  • The PHP will generate the HTML and then save it to an html file. PHP tidy will use the generated html file Commented Sep 4, 2012 at 21:05

1 Answer 1

1

It doesn't appear there is a way to use tidy in php like this. (Even as of php 5.5) After trying lots of variations including stuff which should be valid SGML like <script language="php"> and <!-- <?php echo 1; ?> !--> It appears its actively stripping out php tags.

The tidy library in php is most often used as an output filter; something that takes all the output of your page before its sent to the browser and fixes it. The most basic example of this is right out of the php manual.

<?php
//start the output buffer to capture all page output.
ob_start();
?>
<html>a html document
     <div><?php echo 'do your thing here' ?></div>
</html>
<?php
//get the contents of the output buffer.
$html = ob_get_clean();

// configure tidy
$config = array(
           'indent'         => true,
           'output-xhtml'   => true,
           'wrap'           => 200);
//tidy the html
$tidy = new tidy;
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
// Output the clean html.
echo $tidy;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.