• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP tidy_parse_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中tidy_parse_string函数的典型用法代码示例。如果您正苦于以下问题:PHP tidy_parse_string函数的具体用法?PHP tidy_parse_string怎么用?PHP tidy_parse_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tidy_parse_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __destruct

 public function __destruct()
 {
     try {
         if (!self::$html_set || !self::$head_set) {
             throw new PageException("<b>HTML class exception.</b><br />Either &lt;html&gt; or &lt;head&gt; or &lt;body&gt; 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("&nbsp;", $il4) . $j;
                 echo $linenr . ' : ' . $linedump[$i];
             }
             echo '<hr />';
             self::$output = '';
         } else {
             echo self::$output;
             self::$output = '';
         }
     } catch (PageException $e) {
         echo $e->getMessage();
     }
 }
开发者ID:broozer,项目名称:psa,代码行数:34,代码来源:Page.php


示例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);
}
开发者ID:WhoJave,项目名称:PopClip-Extensions,代码行数:7,代码来源:tidy.php


示例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);
 }
开发者ID:aodkrisda,项目名称:phalcon-code,代码行数:7,代码来源:views-837.php


示例4: tidy

 protected function tidy($content)
 {
     $config = array('output-xhtml' => true);
     $tidy = tidy_parse_string($content, $config, 'utf8');
     $tidy->cleanRepair();
     return (string) $tidy;
 }
开发者ID:gauthierm,项目名称:Spider,代码行数:7,代码来源:TidyParser.php


示例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;
}
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:35,代码来源:tiki-tests_edit.php


示例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;
 }
开发者ID:BGCX261,项目名称:zoocms-svn-to-git,代码行数:37,代码来源:Filter.php


示例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("&", "&amp;", $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;
 }
开发者ID:az0ne,项目名称:diaoyu,代码行数:34,代码来源:BaseModelFilter.php


示例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);
 }
开发者ID:richthegeek,项目名称:Misc,代码行数:8,代码来源:tidyPQ.php


示例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;
 }
开发者ID:ankhzet,项目名称:Ankh,代码行数:8,代码来源:TidyCleaner.php


示例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;
 }
开发者ID:gathercontent,项目名称:htmldiff,代码行数:8,代码来源:Processor.php


示例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;
 }
开发者ID:alcodo,项目名称:alpaca,代码行数:15,代码来源:Image.php


示例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;
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:9,代码来源:pagecontentlib.php


示例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;
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:16,代码来源:tidy_parser.php


示例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);
 }
开发者ID:hadihkhan,项目名称:is,代码行数:11,代码来源:WebPageFilter.php


示例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;
 }
开发者ID:nodefortytwo,项目名称:lp-test,代码行数:16,代码来源:template.php


示例16: onOutputGenerated

 /**
  * Retrieves the actual output intend and parses it to tidyPHP for cleanup
  * cleaned up content the gets set to the grav context again.
  */
 public function onOutputGenerated()
 {
     if ($this->skipCurrentSite($this->grav['uri']->path())) {
         return;
     }
     $originOutput = $this->grav->output;
     $config = array('indent' => $this->_getConfigSetting('indent'), 'indent-spaces' => $this->_getConfigSetting('indent_spaces'), 'wrap' => $this->_getConfigSetting('wrap'), 'hide-comments' => $this->_getConfigSetting('hide_comments'), 'new-blocklevel-tags' => implode(' ', $this->_getConfigSetting('blocklevel_tags')), 'new-empty-tags' => implode(' ', $this->_getConfigSetting('empty_tags')), 'new-inline-tags' => implode(' ', $this->_getConfigSetting('inline_tags')), 'newline' => 'LF');
     /** @var tidy $tidy */
     $tidy = tidy_parse_string($originOutput, $config, 'UTF8');
     $tidy->cleanRepair();
     $this->grav->output = $tidy;
 }
开发者ID:sourcesoldier,项目名称:grav-plugin-tidyhtml,代码行数:16,代码来源:tidyhtml.php


示例17: afterRender

 public function afterRender($event, $view)
 {
     if (!extension_loaded('tidy')) {
         return;
     }
     $options = array('hide-comments' => true, 'tidy-mark' => false, 'indent' => true, 'indent-spaces' => 4, 'new-blocklevel-tags' => 'article,header,footer,section,nav', 'new-inline-tags' => 'video,audio,canvas,ruby,rt,rp', 'doctype' => '<!DOCTYPE HTML>', 'sort-attributes' => 'alpha', 'vertical-space' => false, 'output-xhtml' => true, 'wrap' => 150, 'wrap-attributes' => false, 'break-before-br' => false);
     $buffer = tidy_parse_string($view->getContent(), $options, 'utf8');
     tidy_clean_repair($buffer);
     $buffer = str_replace(array('<html lang="en" xmlns="http://www.w3.org/1999/xhtml">', '<html xmlns="http://www.w3.org/1999/xhtml">'), '<!DOCTYPE html>', $buffer);
     $buffer = str_replace(">\n</script>", "></script>", $buffer);
     $view->setContent((string) $buffer);
 }
开发者ID:niden,项目名称:kolibri,代码行数:12,代码来源:Tidy.php


示例18: render

 /**
  * Trims content, then trims each line of content
  *
  * @param string $content
  * @param string $encoding
  * @throws \RuntimeException
  * @return string
  */
 public function render($content = null, $encoding = 'utf8')
 {
     if (null === $content) {
         $content = $this->renderChildren();
     }
     if (true === $this->hasTidy) {
         $tidy = tidy_parse_string($content, [], $encoding);
         $tidy->cleanRepair();
         return (string) $tidy;
     }
     throw new \RuntimeException('TidyViewHelper requires the PHP extension "tidy" which is not installed or not loaded.', 1352059753);
 }
开发者ID:fluidtypo3,项目名称:vhs,代码行数:20,代码来源:TidyViewHelper.php


示例19: output

function output($title = '', $body = '', $head = '')
{
    global $settings, $authid, $checkleft, $checkright, $head, $error, $error_die;
    if (theme('output_error') != false) {
        $body = theme('output_error');
        $title = 'Error';
        $panels = false;
        $lowerpanel = false;
        $panel = '';
        unset($error_die);
    } else {
        $panels = true;
    }
    //display panels
    if ($panels != false) {
        $panel = theme('displaypanels');
        $lowerpanel = theme('displaylowerpanel');
    }
    if (isset($error) && !empty($error)) {
        $errors = '<br />' . theme('title', 'Error') . theme('start_content') . '<div class="errors"><ul>';
        foreach ($error as $error1) {
            $errors .= '<li>' . $error1 . '</li>';
        }
        $errors .= '</ul></div>' . theme('end_content');
        unset($error);
    } else {
        $errors = '';
    }
    if (isset($_GET['page']) && $_GET['page'] > 1) {
        $title = $title . ' - Page ' . $_GET['page'];
    }
    $output = theme('head', stripslashes($title), $head) . '<body>';
    if ($settings['maintenance_mode'] == 'on') {
        $output .= '<div class="titlebg">WARNING: Maintenance Mode is on</div>';
    }
    $output .= '<div id="container">
	' . theme('top') . theme('links');
    $output .= $panel;
    //display the data
    $output .= $errors . '<br />' . stripslashes($body);
    $output .= $lowerpanel . theme('footer');
    //SEO Friendly Links
    include IN_PATH . '/functions/seofriendlyurls.php';
    //Check if the tidy library is installed
    if (extension_loaded('tidy')) {
        //yay it is, lets clean up all the HTML, so it looks all nice in View Source in your browser :)
        $options = array("indent" => true, 'wrap' => 0);
        $output = tidy_parse_string($output, $options);
        tidy_clean_repair($output);
    }
    die($output);
}
开发者ID:eodivision,项目名称:eoCMS,代码行数:52,代码来源:output.php


示例20: render

 /**
  * Trims content, then trims each line of content
  *
  * @param string $content
  * @throws \RuntimeException
  * @return string
  */
 public function render($content = NULL)
 {
     if (NULL === $content) {
         $content = $this->renderChildren();
     }
     if (TRUE === $this->hasTidy) {
         $configuration = array('output-xml' => TRUE, 'input-xml' => TRUE, 'indent' => TRUE, 'quote-nbsp' => FALSE, 'input-encoding' => 'utf8', 'output-encoding' => 'utf8', 'char-encoding' => 'utf8');
         $tidy = tidy_parse_string($content, $configuration);
         $tidy->cleanRepair();
         return (string) $tidy;
     }
     throw new \RuntimeException('TidyViewHelper requires the PHP extension "tidy" which is not installed or not loaded.', 1352059753);
 }
开发者ID:putheakhem,项目名称:GIB.GradingTool,代码行数:20,代码来源:TidyViewHelper.php



注:本文中的tidy_parse_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP tidy_repair_file函数代码示例发布时间:2022-05-23
下一篇:
PHP tidy_get_output函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap