From 83d113d66917b427e0acbd5d3c9c5d17770023c3 Mon Sep 17 00:00:00 2001 From: FrankZamora Date: Sat, 6 Dec 2025 23:05:51 -0600 Subject: [PATCH] chore(php): add more debug for toc heading detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../Infrastructure/Ui/TableOfContentsRenderer.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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);