src/Core/Template.php
protected function compressHTML($content)
    {
        $content_parts = preg_split(
            '#(</?pre[^>]*>)|(</?script[^>]*>)|(</?style[^>]*>)|(</?textarea[^>]*>)#i',
            $content,
            -1,
            PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
        );

        $content = '';
        $preserve_next = false;
        $optimize_next = false;

        foreach ($content_parts as $part) {
            if (strncasecmp($part, '<pre', 4) === 0 || strncasecmp($part, '<textarea', 9) === 0) {
                $preserve_next = true;
            } elseif (strncasecmp($part, '<script', 7) === 0 || strncasecmp($part, '<style', 6) === 0) {
                $optimize_next = true;
            } elseif ($preserve_next) {
                $preserve_next = false;
            } elseif ($optimize_next) {
                $optimize_next = false;

                $part = str_replace(
                    ["/* <![CDATA[ */\n", "<!--\n", "\n//-->"],
                    ['/* <![CDATA[ */', '', ''],
                    $part
                );
                $part = trim(
                    preg_replace([
                            '@(?<!:)//(?!W3C|DTD|EN).*@',
                            '/[ \n\t]*(;|=|\{|\}|\[|\]|&&|,|<|>|\',|",|\':|":|: |\|\|)[ \n\t]*/'
                        ], [
                            '',
                            '$1'
                        ],
                        $part
                    )
                );
            } else {
                $replace_array = [
                    '/\n ?\n+/' => "\n", // Convert multiple line-breaks
                    '/^[\t ]+</m' => '<', // Remove tag indentation
                    '/>( )?\n</' => '>$1<', // Remove line-breaks between tags
                    '/\n/' => '', // Remove all remaining line-breaks
                    '/ <\/(div|p)>/' => '</$1>' // Remove spaces before closing DIV and P tags
                ];

                $part = str_replace("\r", '', $part);
                $part = trim(preg_replace(array_keys($replace_array), array_values($replace_array), $part));
            }
            $content .= $part;
        }
        return $content;
    }
protected function compressHTML($content)
    {
        $content_parts = preg_split(
            '#(</?pre[^>]*>)|(</?script[^>]*>)|(</?style[^>]*>)|(</?textarea[^>]*>)#i',
            $content,
            -1,
            PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
        );

        $content = '';
        $preserve_next = false;
        $optimize_next = false;

        foreach ($content_parts as $part) {
            if (strncasecmp($part, '<pre', 4) === 0 || strncasecmp($part, '<textarea', 9) === 0) {
                $preserve_next = true;
            } elseif (strncasecmp($part, '<script', 7) === 0 || strncasecmp($part, '<style', 6) === 0) {
                $optimize_next = true;
            } elseif ($preserve_next) {
                $preserve_next = false;
            } elseif ($optimize_next) {
                $optimize_next = false;

                $part = str_replace(
                    ["/* <![CDATA[ */\n", "<!--\n", "\n//-->"],
                    ['/* <![CDATA[ */', '', ''],
                    $part
                );
                $part = trim(
                    preg_replace([
                            '@(?<!:)//(?!W3C|DTD|EN).*@',
                            '/[ \n\t]*(;|=|\{|\}|\[|\]|&&|,|<|>|\',|",|\':|":|: |\|\|)[ \n\t]*/'
                        ], [
                            '',
                            '$1'
                        ],
                        $part
                    )
                );
            } else {
                $replace_array = [
                    '/\n ?\n+/' => "\n", // Convert multiple line-breaks
                    '/^[\t ]+</m' => '<', // Remove tag indentation
                    '/>( )?\n</' => '>$1<', // Remove line-breaks between tags
                    '/\n/' => '', // Remove all remaining line-breaks
                    '/ <\/(div|p)>/' => '</$1>' // Remove spaces before closing DIV and P tags
                ];

                $part = str_replace("\r", '', $part);
                $part = trim(preg_replace(array_keys($replace_array), array_values($replace_array), $part));
            }
            $content .= $part;
        }
        return $content;
    }
@param string $content

@return string