本文整理汇总了PHP中tidy_parse_string函数的典型用法代码示例。如果您正苦于以下问题:PHP tidy_parse_string函数的具体用法?PHP tidy_parse_string怎么用?PHP tidy_parse_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tidy_parse_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __destruct
public function __destruct()
{
try {
if (!self::$html_set || !self::$head_set) {
throw new PageException("<b>HTML class exception.</b><br />Either <html> or <head> or <body> is not set.</b><br />\n\t\t\t\t\tAll these tags need to be used in order to generate valid html forms.");
}
self::$output .= "</body>\n</html>";
if (self::$debug) {
echo '<b>Tidy messages</b><br />';
$tidy = tidy_parse_string(self::$output);
echo nl2br(htmlentities(tidy_get_error_buffer($tidy)));
echo '<hr />';
$linedump = explode("\n", nl2br(htmlentities(str_replace("<br />", "\n", self::$output))));
// var_dump($linedump);
for ($i = 0; $i < sizeof($linedump); ++$i) {
if (trim(str_replace("<br>", "", $linedump[$i])) == '') {
continue;
}
$il = strlen($i);
$il4 = 4 - $il;
$j = $i + 1;
$linenr = str_repeat(" ", $il4) . $j;
echo $linenr . ' : ' . $linedump[$i];
}
echo '<hr />';
self::$output = '';
} else {
echo self::$output;
self::$output = '';
}
} catch (PageException $e) {
echo $e->getMessage();
}
}
示例2: tidy_html
function tidy_html($html)
{
$tidy_config = array('output-xhtml' => true, 'show-body-only' => true);
$tidy = tidy_parse_string($html, $tidy_config, 'UTF8');
$tidy->cleanRepair();
return tidy_get_output($tidy);
}
示例3: afterRender
public function afterRender($event, $view)
{
$tidyConfig = array('clean' => true, 'output-xhtml' => true, 'show-body-only' => true, 'wrap' => 0);
$tidy = tidy_parse_string($view->getContent(), $tidyConfig, 'UTF8');
$tidy->cleanRepair();
$view->setContent((string) $tidy);
}
示例4: tidy
protected function tidy($content)
{
$config = array('output-xhtml' => true);
$tidy = tidy_parse_string($content, $config, 'utf8');
$tidy->cleanRepair();
return (string) $tidy;
}
示例5: get_url
/**
* @param $url
* @param bool $use_tidy
* @return array
*/
function get_url($url, $use_tidy = TRUE)
{
global $cookies;
$smarty = TikiLib::lib('smarty');
$result = array();
$get = get_from_dom($url->getElementsByTagName('get')->item(0));
$post = get_from_dom($url->getElementsByTagName('post')->item(0));
$xpath = $url->getElementsByTagName('xpath')->item(0)->textContent;
$data = $url->getElementsByTagName('data')->item(0)->textContent;
$urlstr = $url->getAttribute("src");
$referer = $url->getAttribute("referer");
$result['data'] = $data;
if (extension_loaded("tidy")) {
$data = tidy_parse_string($data, array(), 'utf8');
tidy_diagnose($data);
if ($use_tidy) {
$result['ref_error_count'] = tidy_error_count($data);
$result['ref_error_msg'] = tidy_get_error_buffer($data);
}
} else {
$result['ref_error_msg'] = tra("Tidy Extension not present");
}
$result['url'] = $urlstr;
$result['xpath'] = $xpath;
$result['method'] = $url->getAttribute("method");
$result['post'] = $post;
$result['get'] = $get;
$result['referer'] = $referer;
return $result;
}
示例6: filter
/**
* Filter a content item's content
*
* @return string
*/
function filter($item, $field = "content", $length = 0)
{
$nodefilters = array();
if (is_a($item, 'Zoo_Content_Interface')) {
$txt = $item->{$field};
$nodefilters = Zoo::getService('content')->getFilters($item);
} else {
$txt = $item;
}
if ($length > 0) {
$txt = substr($txt, 0, $length);
}
if (count($nodefilters)) {
$ids = array();
foreach ($nodefilters as $nodefilter) {
$ids[] = $nodefilter->filter_id;
}
$filters = Zoo::getService('filter')->getFilters($ids);
foreach ($filters as $filter) {
$txt = $filter->filter($txt);
}
if (extension_loaded('tidy')) {
$config = array('indent' => TRUE, 'show-body-only' => TRUE, 'output-xhtml' => TRUE, 'wrap' => 0);
$tidy = tidy_parse_string($txt, $config, 'UTF8');
$tidy->cleanRepair();
$txt = tidy_get_output($tidy);
}
} else {
$txt = htmlspecialchars($txt);
}
return $txt;
}
示例7: tidy
public function tidy($html, $encoding = 'utf-8')
{
if ($html == '') {
return false;
}
$output = '';
$html = trim($html);
//对于非utf-8编辑处理
if ($encoding !== 'utf-8') {
$html = BaseModelCommon::convertEncoding($html, 'utf-8', $encoding);
}
$html = preg_replace("|\\/\\*(.*)\\*\\/|sU", "", $html);
//过滤掉全部注释内容
$html = preg_replace("/<!\\[CDATA\\[(.*?)\\]\\]>/is", "\\1", $html);
//过滤掉CDATA标签
$html = $this->_escapeUnicode($html);
//转义Unicode字符
$tidy_conf = array('output-xhtml' => true, 'show-body-only' => true, 'join-classes' => true);
$html = str_replace("&", "&", $html);
$dom = tidy_parse_string($html, $tidy_conf, 'utf8');
$body = $dom->body();
if ($body->child) {
foreach ($body->child as $child) {
$this->_filterNode($child, $output);
}
}
$html = $this->_unEscapeUnicode($output);
//反转义Unicode字符
if ($encoding !== 'utf-8') {
$html = BaseModelCommon::convertEncoding($html, $encoding, 'utf-8');
}
$html = $this->_insertVideo($html);
return $html;
}
示例8: load_html
function load_html($html)
{
$tidy = tidy_parse_string($html);
tidy_clean_repair($tidy);
$html = tidy_get_html($tidy);
phpQuery::unloadDocuments();
return phpQuery::newDocumentHTML($html);
}
示例9: cleanHtml
public function cleanHtml($html, $encoding = 'utf8')
{
$tidy = tidy_parse_string($html, $this->options(), $encoding = 'utf8');
$tidy->cleanRepair();
$html = join('', $tidy->body()->child ?: []);
$html = str_replace(PHP_EOL, '', $html);
return $html;
}
示例10: prepareHtmlInput
public function prepareHtmlInput($html)
{
$config = array('wrap' => false, 'show-body-only' => true);
$tidyNode = tidy_parse_string($html, $config, 'utf8')->body();
$htmlArray = $this->toArray($tidyNode);
$html = implode("\n", $htmlArray);
return $html;
}
示例11: getPrettyHtml
/**
* Return pretty html.
*
* @param $html
* @return mixed
*/
public function getPrettyHtml($html)
{
// TODO without tidy support
$params = ['show-body-only' => true, 'indent' => true, 'output-html' => true, 'wrap' => 200];
$tidy = tidy_parse_string($html, $params, 'UTF8');
$tidy->cleanRepair();
$this->htmlOutput = $tidy;
return $tidy;
}
示例12: tidy
private function tidy($html)
{
if (function_exists('tidy_parse_string')) {
$tidy = tidy_parse_string($html, array(), 'UTF8');
$tidy->cleanRepair();
$html = $tidy->value;
}
return $html;
}
示例13: parse
/**
* Reads the raw content the page using HTML Tidy.
* @param $response SimpleHttpResponse Fetched response.
* @return SimplePage Newly parsed page.
*/
function parse($response)
{
$this->page = new SimplePage($response);
$tidied = tidy_parse_string($input = $this->insertGuards($response->getContent()), array('output-xml' => false, 'wrap' => '0', 'indent' => 'no'), 'latin1');
$this->walkTree($tidied->html());
$this->attachLabels($this->widgets_by_id, $this->labels);
$this->page->setForms($this->forms);
$page = $this->page;
$this->free();
return $page;
}
示例14: __construct
public function __construct($fileName)
{
$tidy = tidy_parse_string(utf8_encode(file_get_contents($fileName)));
$tidy->cleanRepair();
$html = $tidy->html();
$html = $html->value;
$html = $this->removeTags($html, ["script", "style"]);
$this->dom = new DOMDocument();
$this->dom->preserveWhiteSpace = false;
$this->dom->loadHTML($html);
}
示例15: render
/**
* Straight forward string replacement template engine, could be replaced by a full
* template engine if scope increased.
* @return string
*/
public function render()
{
$template_copy = $this->template;
$template_copy = str_replace('{DESTINATION NAME}', $this->destination->title, $template_copy);
$template_copy = str_replace('{CONTENT}', $this->destination->getBodyHtml(), $template_copy);
$template_copy = str_replace('{NAVIGATION}', $this->renderNavigation(), $template_copy);
//clean up the html to make reviewing easier
$tidy = tidy_parse_string($template_copy, ['indent' => true, 'output-xhtml' => true, 'wrap' => 0], 'utf8');
$tidy->cleanRepair();
return (string) $tidy;
}