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

PHP tidy_get_body函数代码示例

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

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



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

示例1: _tidy

 protected function _tidy($text)
 {
     // tidy up the text
     $tidy = new tidy();
     $tidy->parseString($text, array(), 'utf8');
     $tidy->cleanRepair();
     // get only the body portion
     $body = tidy_get_body($tidy);
     return $body->value;
 }
开发者ID:btweedy,项目名称:foresmo,代码行数:10,代码来源:WikiTest.php


示例2: html_standardization

function html_standardization($html)
{
    if (!function_exists('tidy_repair_string')) {
        return $html;
    }
    $str = tidy_repair_string($html, array('output-xhtml' => true), 'utf8');
    if (!$str) {
        return $html;
    }
    $str = tidy_parse_string($str, array('output-xhtml' => true), 'utf8');
    $standard_html = '';
    $nodes = @tidy_get_body($str)->child;
    if (!is_array($nodes)) {
        $returnVal = 0;
        return $html;
    }
    foreach ($nodes as $n) {
        $standard_html .= $n->value;
    }
    return $standard_html;
}
开发者ID:h3len,项目名称:Project,代码行数:21,代码来源:livcms_frm.php


示例3: fixHTMLCode

	/**
	 * Cleanup HTML code (requires HTML Tidy library).
	 * @param $html (string) htmlcode to fix
	 * @param $default_css (string) CSS commands to add
	 * @param $tagvs (array) parameters for setHtmlVSpace method
	 * @param $tidy_options (array) options for tidy_parse_string function
	 * @return string XHTML code cleaned up
	 * @author Nicola Asuni
	 * @public
	 * @since 5.9.017 (2010-11-16)
	 * @see setHtmlVSpace()
	 */
	public function fixHTMLCode($html, $default_css='', $tagvs='', $tidy_options='') {
		// configure parameters for HTML Tidy
		if ($tidy_options === '') {
			$tidy_options = array (
				'clean' => 1,
				'drop-empty-paras' => 0,
				'drop-proprietary-attributes' => 1,
				'fix-backslash' => 1,
				'hide-comments' => 1,
				'join-styles' => 1,
				'lower-literals' => 1,
				'merge-divs' => 1,
				'merge-spans' => 1,
				'output-xhtml' => 1,
				'word-2000' => 1,
				'wrap' => 0,
				'output-bom' => 0,
				//'char-encoding' => 'utf8',
				//'input-encoding' => 'utf8',
				//'output-encoding' => 'utf8'
			);
		}
		// clean up the HTML code
		$tidy = tidy_parse_string($html, $tidy_options);
		// fix the HTML
		$tidy->cleanRepair();
		// get the CSS part
		$tidy_head = tidy_get_head($tidy);
		$css = $tidy_head->value;
		$css = preg_replace('/<style([^>]+)>/ims', '<style>', $css);
		$css = preg_replace('/<\/style>(.*)<style>/ims', "\n", $css);
		$css = str_replace('/*<![CDATA[*/', '', $css);
		$css = str_replace('/*]]>*/', '', $css);
		preg_match('/<style>(.*)<\/style>/ims', $css, $matches);
		if (isset($matches[1])) {
			$css = strtolower($matches[1]);
		} else {
			$css = '';
		}
		// include default css
		$css = '<style>'.$default_css.$css.'</style>';
		// get the body part
		$tidy_body = tidy_get_body($tidy);
		$html = $tidy_body->value;
		// fix some self-closing tags
		$html = str_replace('<br>', '<br />', $html);
		// remove some empty tag blocks
		$html = preg_replace('/<div([^\>]*)><\/div>/', '', $html);
		$html = preg_replace('/<p([^\>]*)><\/p>/', '', $html);
		if ($tagvs !== '') {
			// set vertical space for some XHTML tags
			$this->setHtmlVSpace($tagvs);
		}
		// return the cleaned XHTML code + CSS
		return $css.$html;
	}
开发者ID:acastellon,项目名称:pasajes_viaticos,代码行数:68,代码来源:tcpdf.php


示例4: array

<?php

// bug report taken from http://news.php.net/php.notes/130628
$inputs = array('<frameset > </frameset>', '<html><frameset> </frameset> </html');
foreach ($inputs as $input) {
    $t = tidy_parse_string($input);
    $t->cleanRepair();
    var_dump(tidy_get_body($t));
}
echo "Done\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:10,代码来源:ext_tidy_tests_029.php


示例5: sanitizeString

 public function sanitizeString($content, $isMultiline = false)
 {
     $content = $this->sanitizeEntities($content);
     if ($isMultiline) {
         //TODO: check if this is redundant now that I'm using apply_filters()'
         $content = $this->sanitizeShortCodes($content);
         $content = apply_filters('the_content', $content);
         $content = wpautop($content);
         if ($this->tidy) {
             $this->tidy->parseString($content, array('anchor-as-name' => false, 'clean' => true), 'utf8');
             $this->tidy->cleanRepair();
             //Tidy makes a full html document, with head section, so get just the body
             //then strip out the body tag
             $content = tidy_get_body($this->tidy);
             $content = rtrim($content, '</body>');
             $content = ltrim($content, '<body>');
         }
         $element = "div";
     } else {
         $element = "span";
     }
     $content = trim($content);
     //using loadHTML because it is more forgiving than loadXML
     $tmpHTML = new DOMDocument('1.0', 'UTF-8');
     @$tmpHTML->loadHTML("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body><{$element} xmlns='http://www.w3.org/1999/xhtml'>{$content}</{$element}></body></html>");
     if ($this->checkImgSrcs) {
         $this->checkImageSources($tmpHTML);
     }
     $contentDiv = $tmpHTML->getElementsByTagName($element)->item(0);
     $imported = $this->dom->importNode($contentDiv, true);
     return $imported;
 }
开发者ID:webremote,项目名称:anthologize,代码行数:32,代码来源:class-tei-dom.php


示例6: render

 /**
  * 
  * Returns a final rendering of the processed text.
  * 
  * This replaces any remaining HTML tokens, un-encodes special
  * Markdown characters, and optionally runs the text through
  * [Tidy][].
  * 
  * [Tidy]: http://php.net/tidy
  * 
  * @param string $text The processed and cleaned text.
  * 
  * @return string The final rendering of the text.
  * 
  */
 public function render($text)
 {
     // replace any remaining HTML tokens
     $text = $this->unHtmlToken($text);
     // replace all special chars in the text.
     $text = $this->unEncode($text);
     if (!$this->_config['tidy']) {
         // tidy explicitly disabled
         return $text;
     }
     // tidy up the text
     $tidy = new tidy();
     $opts = (array) $this->_config['tidy'];
     $tidy->parseString($text, $opts, 'utf8');
     $tidy->cleanRepair();
     // get only the body portion
     $body = trim(tidy_get_body($tidy)->value);
     // remove <body> and </body>
     return substr($body, 6, -7);
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:35,代码来源:Main.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP tidy_get_output函数代码示例发布时间:2022-05-23
下一篇:
PHP tidy_clean_repair函数代码示例发布时间: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