本文整理汇总了PHP中tidy类的典型用法代码示例。如果您正苦于以下问题:PHP tidy类的具体用法?PHP tidy怎么用?PHP tidy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tidy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sphsc3
function sphsc3()
{
$results = array();
$i = 0;
do {
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsaud.asp'; //7-8
// 'https://content.sphsc.washington.edu/sphintra/web2/res_blurb.asp'; // 11
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 14
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsphd.asp'; //15
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidspb.asp'; // 16, 19
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsmed.asp'; // 17, 20
// 'https://content.sphsc.washington.edu/sphintra/web2/factoidsug.asp'; // 18
// 'https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp';
//$uri = 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 19
// No's:
// http://content.sphsc.washington.edu/sphintra/web2/clinic_msg.asp
// http://content.sphsc.washington.edu/sphintra/web2/home_right.asp
// https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp
// http://content.sphsc.washington.edu/sphintra/web2/outreach_msg.asp
$tids = array();
$c = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200, 'hide-comments' => true);
$response = get_page($uri);
$tidy = new tidy();
$tidy->parseString($response, $c, 'utf8');
$tidy->cleanRepair();
preg_match("/<body[^>]*>(.*?)<\\/body>/is", $tidy, $a);
$body = str_replace(array("\n", "\r"), '', $a[1]);
$title = some_words(strip_tags($body));
$results[$title] = $body;
} while ($i++ < 20);
foreach ($results as $k => $v) {
save_item($k, $v, $tids);
}
}
开发者ID:sodacrackers,项目名称:washyacht,代码行数:34,代码来源:wyc_drush_node.php
示例2: tidyClean
function tidyClean()
{
$tidy = new tidy();
$tidy->parseString(self::$html, self::$tidy_config, self::$encoding);
$tidy->cleanRepair();
self::$html = $tidy;
}
开发者ID:rigidus,项目名称:ea,代码行数:7,代码来源:cleaner.php
示例3: repair
public function repair($markup)
{
$tidy = new \tidy();
$tidy->parseString($markup, self::$config, 'utf8');
$tidy->cleanRepair();
return $tidy . '';
}
开发者ID:funddy,项目名称:yodo,代码行数:7,代码来源:TidyMarkupFixer.php
示例4: createContentElements
protected function createContentElements(&$objItem)
{
if ($objItem->tl_content) {
// need to wrap <p> around text for contao
$tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false);
$bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
// $bodyText = $this->convert_external_link_tags($bodyText);
// $bodyText = $this->convert_internal_link_tags($bodyText);
$bodyText = $this->nl2p($bodyText);
$tidy = new \tidy();
$tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
$body = $tidy->body();
$objContent = new \ContentModel();
$objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
$objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
// strip images
// create links from text
$objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
// replace <b> by <strong>
$objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
// replace emails with inserttags
$objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
// strip not allowed tags
$objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
$objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
$objContent->ptable = static::$strTable;
$objContent->pid = $objItem->id;
$objContent->sorting = 16;
$objContent->tstamp = time();
$objContent->type = 'text';
$objContent->save();
}
}
开发者ID:heimrichhannot,项目名称:contao-newsport,代码行数:33,代码来源:NewsImporter.php
示例5: build
/**
* Detects feed types and instantiate appropriate objects.
*
* Our constructor takes care of detecting feed types and instantiating
* appropriate classes. For now we're going to treat Atom 0.3 as Atom 1.0
* but raise a warning. I do not intend to introduce full support for
* Atom 0.3 as it has been deprecated, but others are welcome to.
*
* @param string $feed XML serialization of the feed
* @param bool $strict Whether or not to validate the feed
* @param bool $suppressWarnings Trigger errors for deprecated feed types?
* @param bool $tidy Whether or not to try and use the tidy library on input
*/
function build(DOMDocument $model, $feed, $strict = false, $suppressWarnings = false, $tidy = false)
{
$options = 0;
if ($suppressWarnings) {
$options |= LIBXML_NOWARNING;
$options |= LIBXML_NOERROR;
}
if (empty($feed)) {
throw new XML_Feed_Parser_Exception('Invalid input: file is empty');
}
if (!$model->loadXML($feed, $options)) {
if (extension_loaded('tidy') && $tidy) {
$tidy = new tidy();
$tidy->parseString($feed, array('input-xml' => true, 'output-xml' => true));
$tidy->cleanRepair();
if (!$model->loadXML((string) $tidy)) {
throw new XML_Feed_Parser_Exception('Invalid input: this is not ' . 'valid XML');
}
} else {
throw new XML_Feed_Parser_Exception('Invalid input: this is not valid XML');
}
}
/* detect feed type */
$doc_element = $model->documentElement;
$class = $this->determineClass($doc_element, $suppressWarnings);
/* Instantiate feed object */
$feed = new $class($model, $strict);
$feed->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
return $feed;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:43,代码来源:Factory.php
示例6: send_mail
private static function send_mail($server_cfg, $game_cfg, $report)
{
$to = "";
$random_hash = md5(date('r', time()));
$mime_boundary = "==Multipart_Boundary_x{$random_hash}x";
if ($game_cfg === null) {
$subject = "Instance Utilization Summary";
$bcc = $server_cfg["instance_report_mail_recipients"];
$headers = 'From: ' . $server_cfg["sender"] . "\r\n" . 'Bcc: ' . $bcc . "\r\n" . "Content-Type: multipart/mixed;" . " boundary=\"{$mime_boundary}\"" . 'X-Mailer: PHP/' . phpversion();
$HTMLMessage = file_get_contents($report);
$tidy = new tidy();
$tidy->parseString($HTMLMessage);
$tidy->cleanRepair();
$message = "\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $tidy . "\n\n";
$reportClass = new ReportCollector($server_cfg);
$data = $reportClass->generateCSV();
$message .= "--{$mime_boundary}\n" . "Content-Type:text/csv; \n" . " name=zPerfmonUtilTrend_" . date("MjY") . ".csv \n" . "Content-Transfer-Encoding: 7bit\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
mail($to, $subject, $message, $headers);
} else {
$subject = "Instance Utilization report for {$game_cfg['name']}";
$bcc = $game_cfg["instance_report_mail_recipients"];
$headers = 'From: ' . $server_cfg["sender"] . "\r\n" . 'Bcc: ' . $bcc . "\r\n" . 'Content-Type: text/HTML' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$message = file_get_contents($report);
$tidy = new tidy();
$tidy->parseString($message);
$tidy->cleanRepair();
mail($to, $subject, $tidy, $headers);
}
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:29,代码来源:generate_instance_report.php
示例7: __construct
public function __construct($content)
{
if (extension_loaded('tidy')) {
// using the tidy php extension
$tidy = new tidy();
$tidy->parseString($content, array('output-xhtml' => true, 'numeric-entities' => true, 'wrap' => 0), 'utf8');
$tidy->cleanRepair();
$tidy = str_replace('xmlns="http://www.w3.org/1999/xhtml"', '', $tidy);
$tidy = str_replace(' ', '', $tidy);
} elseif (@shell_exec('which tidy')) {
// using tiny through cli
$CLI_content = escapeshellarg($content);
$tidy = `echo {$CLI_content} | tidy --force-output 1 -n -q -utf8 -asxhtml -w 0 2> /dev/null`;
$tidy = str_replace('xmlns="http://www.w3.org/1999/xhtml"', '', $tidy);
$tidy = str_replace(' ', '', $tidy);
} else {
// no tidy library found, hence no sanitizing
$tidy = $content;
}
$this->simpleXML = @simplexml_load_string($tidy, 'SimpleXMLElement', LIBXML_NOWARNING);
if (!$this->simpleXML) {
throw new Exception('CSSContentParser::__construct(): Could not parse content.' . ' Please check the PHP extension tidy is installed.');
}
parent::__construct();
}
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:25,代码来源:CSSContentParser.php
示例8: tidy
/**
* Filter through Tidy
*
* @param array
* @param string
* @param bool
* @return bool
*/
public static function tidy(array &$headers, &$body, $uncached)
{
$tidy = new tidy();
$tidy->parseString($body, array('clean' => 1, 'bare' => 1, 'hide-comments' => 1, 'doctype' => 'omit', 'indent-spaces' => 0, 'tab-size' => 0, 'wrap' => 0, 'quote-ampersand' => 0, 'output-xhtml' => true, 'quiet' => 1), 'utf8');
$tidy->cleanRepair();
$body = tidy_get_output($tidy);
}
开发者ID:rsms,项目名称:phpab,代码行数:15,代码来源:ResponseFilters.php
示例9: apply
public function apply($str)
{
if (extension_loaded('tidy') && class_exists('tidy')) {
$config = array('doctype' => 'strict', 'drop-proprietary-attributes' => true, 'drop-font-tags' => true, 'escape-cdata' => true, 'indent' => false, 'join-classes' => false, 'join-styles' => true, 'lower-literals' => true, 'output-xhtml' => true, 'show-body-only' => true, 'wrap' => 80);
$str = '<p>tt</p>' . $str;
// Fixes a big issue
$tidy = new tidy();
$tidy->parseString($str, $config, 'utf8');
$tidy->cleanRepair();
$str = (string) $tidy;
$str = preg_replace('#^<p>tt</p>\\s?#', '', $str);
} else {
$str = $this->miniTidy($str);
}
# Removing open comments, open CDATA and processing instructions
$str = preg_replace('%<!--.*?-->%msu', '', $str);
$str = str_replace('<!--', '', $str);
$str = preg_replace('%<!\\[CDATA\\[.*?\\]\\]>%msu', '', $str);
$str = str_replace('<![CDATA[', '', $str);
# Transform processing instructions
$str = str_replace('<?', '>?', $str);
$str = str_replace('?>', '?<', $str);
$str = html::decodeEntities($str, true);
$this->content = '';
xml_parse($this->parser, '<all>' . $str . '</all>');
return $this->content;
}
开发者ID:archcidburnziso,项目名称:Bilboplanet,代码行数:27,代码来源:class.html.filter.php
示例10: filter
/**
*
* Uses the tidy library to tidy HTML output.
*
* @access public
*
* @param string $buffer The source text to be filtered.
*
*/
public function filter($buffer)
{
$tidy = new tidy();
$config = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200);
$tidy->parseString($buffer, $config);
$tidy->cleanRepair();
return $tidy->get_output();
}
开发者ID:BackupTheBerlios,项目名称:phpalmanac-svn,代码行数:17,代码来源:Savant3_Filter_tidy.php
示例11: tidy_html
function tidy_html($html)
{
$config = array('indent' => 2, 'output-xhtml' => true, 'doctype' => 'strict', 'wrap' => 120);
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
return $tidy;
}
开发者ID:stacken,项目名称:webbywiki,代码行数:8,代码来源:wiki_format.php
示例12: filter
public function filter(&$content)
{
$config = array('clean' => true, 'enclose-block-text' => true, 'enclose-text' => true, 'preserve-entities' => true, 'logical-emphasis' => true, 'char-encoding' => 'utf8', 'indent' => 'auto', 'output-xhtml' => true, 'wrap' => 200);
$tidy = new tidy();
$tidy->parseString($this->gethtml($content), $config, 'utf8');
$tidy->cleanRepair();
$content = $this->getbody((string) $tidy);
}
开发者ID:laiello,项目名称:litepublisher,代码行数:8,代码来源:tidyfilter.plugin.class.php
示例13: tidy
protected function tidy($response)
{
$response = str_replace(' ', ' ', $response);
$config = array('output-xhtml' => true);
$tidy = new tidy();
$tidy->parseString($response, $config, 'utf8');
$tidy->cleanRepair();
return (string) $tidy;
}
开发者ID:Br3nda,项目名称:laconica,代码行数:9,代码来源:Shorturl_api.php
示例14: init
public static function init()
{
if (!ob_start(function ($buffer) {
$tidy = new \tidy();
return $tidy->repairString($buffer, ['input-xml' => true, 'indent' => true, 'wrap' => 0, 'output-xml' => true]);
})) {
throw \ErrorException("ob_start failed", null, null, __FILE__, __LINE__);
}
}
开发者ID:roman-rybalko,项目名称:wcs,代码行数:9,代码来源:xml_formatter.php
示例15: getURL
public function getURL($url)
{
$data = "awerawer";
// in my code, $data is downloaded from a site
$tidy = new tidy();
$tidy->parseString($data, $this->tidyconfig, 'utf8');
$tidy->cleanRepair();
return $tidy;
}
开发者ID:gleamingthecube,项目名称:php,代码行数:9,代码来源:ext_tidy_tests_027.php
示例16: minify
public static function minify($content, $options = array())
{
$options = array_merge(array('clean' => false, 'hide-comments' => true, 'wrap' => 0, 'input-encoding' => 'utf8', 'output-encoding' => 'utf8', 'preserve-entities' => true), $options, array('show-errors' => 0, 'show-warnings' => false, 'force-output' => true, 'tidy-mark' => false));
$tidy = new tidy();
$tidy->parseString($content, $options);
$tidy->cleanRepair();
$content = $tidy->value;
return $content;
}
开发者ID:rongandat,项目名称:sallumeh,代码行数:9,代码来源:HTMLTidy.php
示例17: Clean
/**
*
* Cleans the html
* @param string $html String cotaining the html to clean
* @return string Cleaned an tidyed
*/
public static function Clean($html)
{
$html = Html::BurnerClean($html);
$config = array("show-body-only" => true, "alt-text" => "Pic without description", "hide-endtags" => false, "output-xhtml" => true);
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
return $tidy;
}
开发者ID:jorgefuertes,项目名称:qPlanet,代码行数:15,代码来源:Html.class.php
示例18: tidyhtml
function tidyhtml($input)
{
$config = array('show-errors' => 0, 'show-warnings' => false, 'break-before-br' => true, 'indent' => true, 'indent-attributes' => true, 'add-xml-decl' => false, 'force-output' => true, 'fix-backslash' => false, 'merge-divs' => false, 'merge-spans' => false, 'doctype' => 'omit', 'enclose-block-text' => true, 'drop-empty-paras' => false, 'output-html' => true, 'show-body-only' => true, 'wrap' => 1);
$tidy = new tidy();
$tidy->parseString($input, $config, 'utf8');
$tidy->cleanRepair();
// Output
return $tidy;
}
开发者ID:TBoonX,项目名称:SlideWiki,代码行数:9,代码来源:CompareController.php
示例19: tidyHtml
function tidyHtml($html)
{
$config = ["indent" => 2, "clean" => false, "char-encoding" => "utf8"];
$tidy = new tidy();
$tidy->parseString($html, $config, 'utf8');
$tidy->cleanRepair();
$ret = $tidy->html()->child[1]->value;
$ret = substr($ret, 7, -7);
return $ret;
}
开发者ID:Bodigrim,项目名称:durmstrang,代码行数:10,代码来源:misc.php
示例20: preView
/**
* @param $output
* @return \tidy
*/
public function preView($output)
{
$config = array('show-body-only' => false, 'clean' => true, 'char-encoding' => 'UTF8', 'add-xml-decl' => true, 'add-xml-space' => true, 'output-html' => false, 'output-xml' => false, 'output-xhtml' => true, 'numeric-entities' => false, 'ascii-chars' => false, 'doctype' => 'auto', 'bare' => true, 'fix-uri' => true, 'indent' => true, 'indent-spaces' => 4, 'tab-size' => 4, 'wrap-attributes' => true, 'wrap' => 0, 'indent-attributes' => true, 'join-classes' => true, 'join-styles' => false, 'enclose-block-text' => true, 'fix-bad-comments' => true, 'fix-backslash' => true, 'replace-color' => false, 'wrap-asp' => false, 'wrap-jste' => false, 'wrap-php' => false, 'write-back' => true, 'drop-proprietary-attributes' => false, 'hide-comments' => true, 'hide-endtags' => false, 'literal-attributes' => false, 'drop-empty-paras' => true, 'enclose-text' => true, 'quote-ampersand' => true, 'quote-marks' => false, 'quote-nbsp' => true, 'vertical-space' => true, 'wrap-script-literals' => false, 'tidy-mark' => true, 'merge-divs' => false, 'repeated-attributes' => 'keep-last', 'break-before-br' => true);
header('Content-type: text/html; charset=utf-8');
$tidy = new \tidy();
$tidy->parseString($output, $config, 'UTF8');
$tidy->cleanRepair();
return $tidy;
// Output
}
开发者ID:stonedz,项目名称:pff2,代码行数:14,代码来源:TidyCleaner.php
注:本文中的tidy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论