mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 12:30:27 +08:00
Page nav: Fixed nbsp being represented as nothing
Now represented in page nav using a normal space to avoid complete removal of space. Added test to cover. For #4836
This commit is contained in:
parent
b7d4bd5bce
commit
77f125208e
|
@ -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 [
|
||||
|
|
|
@ -469,6 +469,20 @@ class PageContentTest extends TestCase
|
|||
], $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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user