public function testFuckedUpHtmlContent() { $testData = array('<pre> this dumb html has no ending tag' => '<pre> this shit html has no ending tag', '<a href="shit"><pre> this shit html is not that great </a></pre>' => '<a href="shit"><pre> this shit html is not that great </a></pre>'); foreach ($testData as $expected => $data) { $p = new \Embera\HtmlProcessor(array('a', 'pre', 'img'), array('shit' => 'dumb')); $result = $p->process($data); $this->assertEquals($result, $expected); } }
/** * Embeds known/available services into the * given text. * * @param string $body * @return string */ public function autoEmbed($body = null) { if (!is_string($body)) { $this->errors[] = 'For auto-embedding purposes, the input must be a string'; } elseif ($data = $this->getUrlInfo($body)) { $table = array(); foreach ($data as $url => $service) { if (!empty($service['html'])) { $table[$url] = $service['html']; } } // Determine wether the body looks like HTML or just plain text. if (strpos($body, '>') !== false) { $processor = new \Embera\HtmlProcessor($this->config['ignore_tags'], $table); return $processor->process($body); } return strtr($body, $table); } return $body; }