From 57c344f924694fc41bdef635c3ab456882edf3fe Mon Sep 17 00:00:00 2001 From: Emma De Silva Date: Fri, 4 Sep 2026 18:04:25 +0200 Subject: [PATCH 1/2] Strip Markdown from sidebar table of contents --- .../Framework/Actions/GeneratesTableOfContents.php | 2 +- .../Unit/GeneratesSidebarTableOfContentsTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php b/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php index 45ade6461f1..1a4a0fdd27e 100644 --- a/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php +++ b/packages/framework/src/Framework/Actions/GeneratesTableOfContents.php @@ -147,7 +147,7 @@ protected function isHeadingWithinBounds(array $heading): bool protected function createTableItem(array $heading): array { return [ - 'title' => $heading['title'], + 'title' => (new ConvertsMarkdownToPlainText($heading['title']))->execute(), 'identifier' => $heading['identifier'], 'children' => [], ]; diff --git a/packages/framework/tests/Unit/GeneratesSidebarTableOfContentsTest.php b/packages/framework/tests/Unit/GeneratesSidebarTableOfContentsTest.php index 0b0b30ed0c8..90601be920d 100644 --- a/packages/framework/tests/Unit/GeneratesSidebarTableOfContentsTest.php +++ b/packages/framework/tests/Unit/GeneratesSidebarTableOfContentsTest.php @@ -170,6 +170,19 @@ public function testNonHeadingMarkdownIsIgnored() ); } + public function testMarkdownIsStrippedFromHeadingTitles() + { + $markdown = '## To learn more, head over to the [Quickstart page](quickstart).'; + + $this->assertSame([ + [ + 'title' => 'To learn more, head over to the Quickstart page.', + 'identifier' => 'to-learn-more-head-over-to-the-quickstart-pagequickstart', + 'children' => [], + ], + ], (new GeneratesTableOfContents($markdown))->execute()); + } + public function testWithNoLevelOneHeading() { $markdown = <<<'MARKDOWN' From c02700dce32c00380f15ddeab62175fc66e6832e Mon Sep 17 00:00:00 2001 From: Emma De Silva Date: Fri, 4 Sep 2026 18:51:23 +0200 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb40f5cefd4..3bc68829199 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ _Changes to the realtime compiler requires an update to v4.5 or later of the `hy - for now removed features. ### Fixed +- Fixed Markdown syntax being displayed in the sidebar table of contents in https://github.com/hydephp/develop/pull/2607 - Fixed Markdown-to-plain-text conversion consuming unrelated content after ATX headings and stripping literal trailing hashes in https://github.com/hydephp/develop/pull/2590 - Improved documentation page detection in MarkdownService so it works for child classes in https://github.com/hydephp/develop/pull/2332 - Fixed bug causing build manifest to not generate when a site has dynamic pages in https://github.com/hydephp/develop/pull/2450