PressBooks\Modules\Import\Epub\Epub201::regexSearchReplace PHP Метод

regexSearchReplace() защищенный Метод

Cleans imported html of unwanted tags
protected regexSearchReplace ( string $html ) : string
$html string
Результат string
    protected function regexSearchReplace($html)
    {
        // Remove auto-created <html> <body> and <!DOCTYPE> tags.
        $result = preg_replace('/^<!DOCTYPE.+?>/', '', str_replace(array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $html));
        if (true == $this->isPbEpub) {
            // Remove PB created div id (on EPUB201 Export) that will generate a princexml error on re-export
            // @see createPartsAndChapters() in export/epub/class-pb-epub201.php
            $result = preg_replace('/(?:<div class="chapter+(.*)" id="(.*)">)/isU', '<div>', $result);
            // Remove PB generated content that is superfluous in a WP/PB environment
            // @see createPartsAndChapters() in export/epub/class-pb-epub201.php
            $result = preg_replace('/(?:<div class="chapter-title-wrap"[^>]*>)(.*)<\\/div>/isU', '', $result);
            // Remove PB generated author content to avoid duplicate content, (it's already copied to metadata as pb_section_author )
            $result = preg_replace('/(?:<h2 class="chapter-author"[^>]*>)(.*)<\\/h2>/isU', '', $result);
            // Replace PB generated div class="ugc chapter">
            $result = preg_replace('/(?:<div class="ugc+(.*)">)/isU', '<div>', $result);
            // Remove PB generated nonindent/indent class
            $result = preg_replace('/(?:<p class="(.*)+indent">)/isU', '<p>', $result);
        }
        return $result;
    }