Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An alternative to php tidy?

Tags:

php

tidy

htmltidy

I use php tidy to process html input in my database,

$fragment = tidy_repair_string($dom->saveHTML(), array('output-xhtml'=>1,'show-body-only'=>1));

I have this php_tidy turned on in my server but my live server doesn't support tidy,

Fatal error: Call to undefined function tidy_repair_string() in /customers/0/5/a/mysite.com/httpd.www/models/functions.php on line 587

Any alternative can I have to fix this problem?

like image 540
Run Avatar asked Jul 31 '11 18:07

Run


3 Answers

I found htmLawed to be very fast. I found it when looking for an alternative to HTMLPurifier, which was very slow.

like image 154
Justin Avatar answered Oct 06 '22 19:10

Justin


Or simply pass through the DOMDocument object:

$dirty = "<xml>some content</xml>"
$x = new DOMDocument;
$x->loadHTML($dirty);
$clean = $x->saveXML();
like image 36
Flavien Volken Avatar answered Oct 06 '22 20:10

Flavien Volken


HTML Purifier can rewrite HTML to be standards-compliant like HTML Tidy. If you need to filter that input for XSS prevention, etc., it will do that as well.

It's all PHP, so you should be able to use it on any server.

like image 43
Chris Hepner Avatar answered Oct 06 '22 18:10

Chris Hepner