src/Core/Helper.php
public static function formatHTMLString($str, $removing_doctype = true)
    {
        $DOCUMENT = new DOMDocument();
        @$DOCUMENT->loadHTML(mb_convert_encoding($str, 'HTML-ENTITIES', 'UTF-8'));
        $content = $DOCUMENT->saveHTML($DOCUMENT->documentElement);
        if ($removing_doctype) {
            return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $content);
        }

        return $content;
    }
public static function formatHTMLString($str, $removing_doctype = true)
    {
        $DOCUMENT = new DOMDocument();
        @$DOCUMENT->loadHTML(mb_convert_encoding($str, 'HTML-ENTITIES', 'UTF-8'));
        $content = $DOCUMENT->saveHTML($DOCUMENT->documentElement);
        if ($removing_doctype) {
            return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $content);
        }

        return $content;
    }
处理HTML字符串，清除未闭合的HTML标签等

@param string $str HTML字符串
@param bool $removing_doctype
@return string