|
tidy_clean_repair
Execute configured cleanup and repair operations on parsed markup
(PHP 5, PECL tidy:0.5.2-1.2)
Example 2536. tidy_clean_repair() example<?php The above example will output: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> Code Examples / Notes » tidy_clean_repairdavid dot thalmann
I use the tidy extension in my board, but i wanted to restric some html-tags and attributes for my users... I found out, that if you use cleanRepair(), the object will be the string... sounds strange, watch that: <?php class myTidy extends tidy { public function __construct($string, $config = array(), $encoding = "utf8") { if(!is_array($config) || empty($config)) // default config $config = array( "doctype" => "omit", "logical-emphasis" => true, "show-body-only" => true, "char-encoding" => "utf8", "ident" => true, "wrap" => 0 ); if(!is_string($encoding)) // default encoding $encoding = "utf8"; parent::parseString($string, $config, $encoding); parent::cleanRepair(); return parent; // !!! Return the object !!! } } ?> And now with "myFunctions" (e.g. restrict attributes / tags via regEx): <?php class myTidy extends tidy { public function __construct($string, $config = array(), $encoding = "utf8") { if(!is_array($config) || empty($config)) $config = array( "doctype" => "omit", "logical-emphasis" => true, "show-body-only" => true, "char-encoding" => "utf8", "ident" => true, "wrap" => 0 ); if(!is_string($encoding)) $encoding = "utf8"; parent::parseString($string, $config, $encoding); parent::cleanRepair(); $string = myFunctions(parent); return $string; } } ?> |
Change Languageob_tidyhandler tidy_access_count tidy_clean_repair tidy_config_count tidy::__construct tidy_diagnose tidy_error_count tidy_get_body tidy_get_config tidy_get_error_buffer tidy_get_head tidy_get_html_ver tidy_get_html tidy_get_opt_doc tidy_get_output tidy_get_release tidy_get_root tidy_get_status tidy_getopt tidy_is_xhtml tidy_is_xml tidy_load_config tidy_node->get_attr tidy_node->get_nodes tidy_node->next tidy_node->prev tidy_parse_file tidy_parse_string tidy_repair_file tidy_repair_string tidy_reset_config tidy_save_config tidy_set_encoding tidy_setopt tidy_warning_count tidyNode->hasChildren tidyNode->hasSiblings tidyNode->isAsp tidyNode->isComment tidyNode->isHtml tidyNode->isJste tidyNode->isPhp tidyNode->isText tidyNode::getParent |