Now represented in page nav using a normal space to avoid complete
removal of space.
Added test to cover.
For #4836
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 [
], $navMap[2]);
}
+ public function test_get_page_nav_respects_non_breaking_spaces()
+ {
+ $content = '<h1 id="testa">Hello There</h1>';
+ $pageContent = new PageContent(new Page(['html' => $content]));
+ $navMap = $pageContent->getNavigation($content);
+
+ $this->assertEquals([
+ 'nodeName' => 'h1',
+ 'link' => '#testa',
+ 'text' => 'Hello There',
+ 'level' => 1,
+ ], $navMap[0]);
+ }
+
public function test_page_text_decodes_html_entities()
{
$page = $this->entities->page();