diff --git a/Public/TableOfContents/Infrastructure/Ui/TableOfContentsRenderer.php b/Public/TableOfContents/Infrastructure/Ui/TableOfContentsRenderer.php index 5e425ab8..98afecb2 100644 --- a/Public/TableOfContents/Infrastructure/Ui/TableOfContentsRenderer.php +++ b/Public/TableOfContents/Infrastructure/Ui/TableOfContentsRenderer.php @@ -128,10 +128,21 @@ final class TableOfContentsRenderer implements RendererInterface error_log("{$debugPrefix}: post_id={$post->ID}, raw_content_length=" . strlen($post->post_content)); + // Check if raw content has headings + $rawHeadingCount = preg_match_all('/]*>/i', $post->post_content, $rawMatches); + error_log("{$debugPrefix}: raw_headings_count={$rawHeadingCount}"); + $content = apply_filters('the_content', $post->post_content); error_log("{$debugPrefix}: filtered_content_length=" . strlen($content)); + // Check if filtered content has headings + $filteredHeadingCount = preg_match_all('/]*>/i', $content, $filteredMatches); + error_log("{$debugPrefix}: filtered_headings_count={$filteredHeadingCount}"); + + // Log first 500 chars of filtered content for diagnosis + error_log("{$debugPrefix}: filtered_content_preview=" . substr(strip_tags($content), 0, 300)); + $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML('' . $content);