protected static clean_html ( string $html ) : string | ||
$html | string | |
리턴 | string |
protected static function clean_html($html)
{
// Because PHP's DomDocument doesn't like HTML5 tags, ignore errors.
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html);
libxml_clear_errors(true);
// Find the first-level nodes of the body tag.
$element = $dom->getElementsByTagName('body')->item(0)->childNodes->item(0);
$html = $dom->saveHTML($element);
return preg_replace('#<[^/>][^>]*></[^>]+>#', '', $html);
}