當前位置: 首頁>>代碼示例>>PHP>>正文


PHP tidy::diagnose方法代碼示例

本文整理匯總了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;
開發者ID:gleamingthecube,項目名稱:php,代碼行數:13,代碼來源:ext_tidy_tests_020.php

示例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);
 }
開發者ID:NicolasSchmutz,項目名稱:cm,代碼行數:26,代碼來源:TestCase.php

示例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);
}
開發者ID:pacew,項目名稱:ccast,代碼行數:38,代碼來源:abase.php


注:本文中的tidy::diagnose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。