JoliTypo\Fixer::fix PHP Method

fix() public method

public fix ( string $content ) : string
$content string HTML content to fix
return string Fixed content
    public function fix($content)
    {
        $trimmed = trim($content);
        if (empty($trimmed)) {
            return $content;
        }
        // Get a clean new StateBag
        $this->stateBag = new StateBag();
        $dom = $this->loadDOMDocument($trimmed);
        $this->processDOM($dom, $dom);
        $content = $this->exportDOMDocument($dom);
        return $content;
    }

Usage Example

Exemplo n.º 1
0
 public function testProtectedTags()
 {
     $fixer = new Fixer(array('Ellipsis'));
     $fixer->setProtectedTags(array('pre', 'a'));
     $fixed_content = $fixer->fix('<p>Fixed...</p> <pre>Not fixed...</pre> <p>Fixed... <a>Not Fixed...</a>.</p>');
     $this->assertEquals('<p>Fixed&hellip;</p> <pre>Not fixed...</pre> <p>Fixed&hellip; <a>Not Fixed...</a>.</p>', $fixed_content);
 }