This project is currently developed for D8-only, and makes a text filter available to be added to text formats. It simply parses the text field for heading elements using an xpath query, assigns ids to them, and generates a hierarchial table of contents that is prepended to the field content.

Link to project page https://www.drupal.org/sandbox/lpeabody/2594843

Clone via git clone --branch 8.x-1.x http://git.drupal.org/sandbox/lpeabody/2594843.git toc_text_filter

CommentFileSizeAuthor
#5 toc_screenshot.png74.73 KBDanny_Joris
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lpeabody created an issue. See original summary.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

mikemiles86’s picture

Status: Needs review » Needs work

In src/Plugin/Filter/FilterToc.php on line #61.

$toc .= "<li><a href='#toc_{$index}'>{$child->textContent}</a>";

you should be using \Drupal::l() to build the link.

lpeabody’s picture

Status: Needs work » Needs review

Thanks for the comment @mikemiles86. I've updated the 8.x-1.x branch which contains these changes.

Danny_Joris’s picture

FileSize
74.73 KB

Automated Review

There are a few minor code style improvements possible: http://pareview.sh/pareview/httpgitdrupalorgsandboxlpeabody2594843git-8x-1x

Manual Review

Individual user account
Yes
No duplication
There are plenty of TOC modules, but currently there's only one listed with a D8 version. I see two listed that take the Text Filter approach, just like this module, but I don't think any use XPath to grab the headers. Maybe it's possible to join forces with the toc_filter module?
Master Branch
Yes
Licensing
Yes
3rd party assets/code
Yes
README.txt/README.md
Yes
Code long/complex enough for review
I believe so. It's a small module, but it doesn't need much more, and the code looks good.
Secure code
As far as I can tell, yes.
Coding style & Drupal API usage
a few minor code style improvements possible: http://pareview.sh/pareview/httpgitdrupalorgsandboxlpeabody2594843git-8x-1x , but uses the Drupal API well, and looks good overall.

- I did find one bug where a list item isn't nested in <ol></ol> tags. Maybe it's because the header nesting didn't happen in the correct order? See attached screenshot.
- I'm also wondering if the ordered list style won't be a hindrance rather than an advantage in some cases. Maybe this can be configurable? Currently this renders nested lists with single digits. I would think a notation like this: 2.1) 2.1.1) 2.1.2), etc is often preferred. Adding support for CSS counters could be something to look into.

asiby’s picture

Status: Needs review » Needs work

The are still few errors found by the automated review as mentioned by Danny.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.