sanitize($source['content_html']); $doc = new DOMDocument; $old = libxml_use_internal_errors(true); $doc->loadHTML('
'.$source['content_html'].'', LIBXML_NONET); libxml_clear_errors(); libxml_use_internal_errors($old); $headings = []; foreach ($doc->getElementsByTagName('h1') as $heading) { $headings[] = str_contains(html_entity_decode(strip_tags($projected), ENT_QUOTES | ENT_HTML5, 'UTF-8'), $heading->textContent); } $checks[] = ['legacy_id' => $article['id'], 'original_sha256_preserved' => true, 'source_h1_count' => count($headings), 'heading_text_preserved' => ! in_array(false, $headings, true), 'projected_h1_count' => preg_match_all('/