diff --git a/app/Entities/Tools/PageContent.php b/app/Entities/Tools/PageContent.php index 4f68b828f..d2f5de65c 100644 --- a/app/Entities/Tools/PageContent.php +++ b/app/Entities/Tools/PageContent.php @@ -379,7 +379,7 @@ class PageContent protected function headerNodesToLevelList(DOMNodeList $nodeList): array { $tree = collect($nodeList)->map(function (DOMElement $header) { - $text = trim(str_replace("\xc2\xa0", '', $header->nodeValue)); + $text = trim(str_replace("\xc2\xa0", ' ', $header->nodeValue)); $text = mb_substr($text, 0, 100); return [ diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php index 28897c14d..23a38b573 100644 --- a/tests/Entity/PageContentTest.php +++ b/tests/Entity/PageContentTest.php @@ -469,6 +469,20 @@ class PageContentTest extends TestCase ], $navMap[2]); } + public function test_get_page_nav_respects_non_breaking_spaces() + { + $content = '