本文整理汇总了PHP中tidy::diagnose方法的典型用法代码示例。如果您正苦于以下问题:PHP tidy::diagnose方法的具体用法?PHP tidy::diagnose怎么用?PHP tidy::diagnose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tidy
的用法示例。
在下文中一共展示了tidy::diagnose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tidy
<?php
$tidy = new tidy();
$str = <<<EOF
<p>Isto é um texto em Português<br>
para testes.</p>
EOF;
$tidy->parseString($str, array('output-xhtml' => 1), 'latin1');
$tidy->cleanRepair();
$tidy->diagnose();
var_dump(tidy_warning_count($tidy) > 0);
var_dump(strlen($tidy->errorBuffer) > 50);
echo $tidy;
示例2: assertTidy
/**
* @param CM_Dom_NodeList $page
* @param bool $warnings
*/
public static function assertTidy(CM_Dom_NodeList $page, $warnings = true)
{
if (!extension_loaded('tidy')) {
self::markTestSkipped('The tidy extension is not available.');
}
$html = $page->getHtml();
$tidy = new tidy();
$tidyConfig = array('show-errors' => 1, 'show-warnings' => $warnings);
$tidy->parseString($html, $tidyConfig, 'UTF8');
//$tidy->cleanRepair();
$tidy->diagnose();
$lines = array_reverse(explode("\n", $tidy->errorBuffer));
$content = '';
foreach ($lines as $line) {
if (empty($line) || $line == 'No warnings or errors were found.' || strpos($line, 'Info:') === 0 || strpos($line, 'errors were found!') > 0 || strpos($line, 'proprietary attribute') != false) {
// ignore
} else {
$content .= $line . PHP_EOL;
}
}
self::assertEmpty($content, $content);
}
示例3: do_tidy
function do_tidy($raw_html, $tag_for_error = "")
{
$html = "<!DOCTYPE html PUBLIC" . " '-//W3C//DTD XHTML 1.0 Transitional//EN'" . " 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'" . ">" . "<html xmlns='http://www.w3.org/1999/xhtml'>" . "<head>" . "<meta http-equiv='Content-Type'" . " content='text/html; charset=utf-8' />" . "<title></title>" . "</head>" . "<body>";
$html .= $raw_html;
$html .= "\n</body></html>\n";
$config = array();
$config['indent'] = 1;
$config['indent-spaces'] = 4;
$config['indent-attributes'] = 1;
$config['wrap'] = 120;
$config['gnu-emacs'] = 1;
$config['literal-attributes'] = 1;
$config['output-xhtml'] = 1;
$config['quote-nbsp'] = 1;
$config['show-errors'] = 10;
$config['vertical-space'] = 1;
// $config['TidyCharEncoding'] = "utf8";
$config['show-body-only'] = 1;
$config['force-output'] = 1;
$config['quiet'] = 1;
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
$tidy->diagnose();
if ($tidy->errorBuffer) {
global $tidy_errs;
if (!isset($tidy_errs)) {
$tidy_errs = "";
}
if ($tag_for_error) {
$tidy_errs .= sprintf("<p>errors in %s</p>\n", h($tag_for_error));
}
$tidy_errs .= "<pre>\n";
$tidy_errs .= htmlentities($tidy->errorBuffer, ENT_QUOTES, 'UTF-8');
$tidy_errs .= "</pre>\n";
}
return trim($tidy);
}