strata / frontend

The front of Headless CMS. Build an efficient front-end website taking content from multiple data sources.
MIT License
13 stars 5 forks source link

Fix TableOfContents::parseHeadingsFromHtml() not being recursive #95

Closed jean-gui closed 3 years ago

jean-gui commented 3 years ago

TableOfContents::parseHeadingsFromHtml() didn't go into HTML elements that were not in the list of levels. So for example passing a div containing headings to this function wouldn't return any TOC.

The fix is easy and simply makes sure the recursive call is applied to all elements.

Note: I am unable to run tests so I can't modify them to make sure this new behavior works properly.

simonrjones commented 3 years ago

Thanks for fixing @jean-gui - I added a test in tests/View/TableOfContentTest.php and added example HTML to test this issue. See function testNestedHeadings

I tested this directly in PHPUnit via: ./vendor/bin/phpunit tests/View/TableOfContentTest.php --filter testNestedHeadings