{"id":6723,"date":"2024-07-30T12:01:04","date_gmt":"2024-07-30T04:01:04","guid":{"rendered":""},"modified":"2024-07-30T12:01:04","modified_gmt":"2024-07-30T04:01:04","slug":"tidy\u4f7f\u7528\u7b80\u4ecb_Tile\u8f6f\u4ef6\u662f\u5e72\u561b\u7684","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6723.html","title":{"rendered":"tidy\u4f7f\u7528\u7b80\u4ecb_Tile\u8f6f\u4ef6\u662f\u5e72\u561b\u7684"},"content":{"rendered":"
\n
Tidy is a binding for the Tidy HTML clean and repair utility
Tidy\u662f\u4e00\u79cd\u6574\u7406\u548c\u4fee\u590d\u4f60\u7684HTML\u7684\u5de5\u5177,\u652f\u6301\u9762\u5411\u5bf9\u8c61\u6216\u9762\u5411\u8fc7\u7a0b\u65b9\u5f0f\u8c03\u7528,\u4e0b\u9762\u7b80\u5355\u8bf4\u8bf4\u5b83\u7684\u7528\u6cd5:
1)\u5bf9\u8c61\u65b9\u5f0f<\/p>\n
<?php 2)\u8fc7\u7a0b\u65b9\u5f0f<\/p>\n <?php <?php \u5176\u5b83\u51fd\u6570: tidy_get_body \/\/\u8fd4\u56debody\u6807\u8bb0\u90e8\u5206 \n<\/p><\/div>\n<\/div>\n
$html = '<p>test<\/I>'; \/\/\u8981\u5904\u7406\u7684\u5b57\u4e32
$tidy = new tidy;
$tidy->parseString($html);
$tidy->CleanRepair();
echo tidy_get_output($tidy); \/\/\u8f93\u51fa\u5904\u7406\u540e\u7684\u7ed3\u679c
?><\/span><\/strong><\/p>\n
$html =\" <p>error<br>another line<\/i>\";
$config = array('indent' => TRUE,
'output-xhtml' => TRUE,
'wrap' => 200);
$tidy = tidy_parse_string($buffer, $config, 'UTF8'); \/\/\u8fd4\u56de\u7684\u662ftidy\u5bf9\u8c61
$tidy->CleanRepair($tidy);
echo tidy_get_output($tidy); \/\/\u8f93\u51fa\u5904\u7406\u540e\u7684\u7ed3\u679c
?><\/span><\/strong><\/p>\n
$html =\" <p>error<br>another line<\/i>\";
$config = array('indent' => TRUE,
'output-xhtml' => TRUE,
'wrap' => 200);
$tidy = tidy_repair_string($html, $config, 'UTF8'); \/\/\u8fd4\u56de\u7684\u662ftidy\u5bf9\u8c61
echo $tidy;
?><\/span><\/strong><\/p>\n
tidy tidy_parse_file \/\/\u9700\u8981\u7528tidy_get_X\u7cfb\u5217\u5904\u7406\u8fd4\u56de
String tidy_repair_file \/\/\u53ef\u4ee5\u76f4\u63a5echo
tidy tidy_parse_string
String tidy_repair_string
\u5982\u679c\u4f60\u9700\u8981\u5355\u72ec\u5904\u7406HTML\u5185\u5bb9\u7684\u67d0\u4e9b\u6307\u5b9a\u6807\u8bb0,\u9700\u8981\u7528tidy_parse_*\u914d\u5408tidy_clean_repair\u4f7f\u7528,\u5e76\u4f7f\u7528tidy_get_*\u7cfb\u5217\u8f93\u51fa\u7ed3\u679c(tidy_get_*\u63a5\u53d7\u7684\u53c2\u6570\u4e3atidy\u5bf9\u8c61)
\u5982\u679c\u53ea\u662f\u5bf9\u6574\u4e2a\u5185\u5bb9\u7b80\u5355\u5904\u7406\u5e76\u8f93\u51fa,\u76f4\u63a5\u7528tidy_repair_*\u5904\u7406\u5e76\u8fd4\u56de\u7ed3\u679c\u5b57\u4e32,\u518decho\u5c31\u53ef\u4ee5\u4e86<\/p>\n
tidy_get_config \/\/\u8fd4\u56de\u53c2\u6570\u914d\u7f6e ,\u5177\u4f53\u914d\u7f6e\u8bf7\u53c2\u9605http:\/\/tidy.sourceforge.net\/docs\/quickref.html
tidy_get_head \/\/head\u6807\u8bb0\u90e8\u5206
tidy_get_html \/\/html\u90e8\u5206(\u5168\u6587?)<\/p>\n\n