Skip to content

Keep forum thread posts that look like related post cards - #438

Open
rnavarro wants to merge 1 commit into
kepano:mainfrom
rnavarro:fix/forum-thread-replies-removed
Open

rnavarro wants to merge 1 commit into
kepano:mainfrom
rnavarro:fix/forum-thread-replies-removed

Conversation

@rnavarro

Copy link
Copy Markdown

I use defuddle (through JSDOM) to read forum threads, and after upgrading from 0.14.0 to 0.19.5 an SMF topic on eevblog.com came back with 8 of its 19 replies. Every post from reply #9 on was gone. It reproduces on main (556d74e) under both JSDOM and linkedom, and removeContentPatterns: false brings all 19 back.

debug.removals shows the chain: reply #9 is removed as "related post cards", its hr.post_separator as "thin CTA section", and every later post as "trailing non-content".

What matches: in removeByContentPattern, the headingless card loop treats an element as a card grid when at least 70% of its children each hold an img plus a heading or a[href]. One SMF post's div.post_wrapper has three children that each fit: the poster sidebar (status icon and profile link), the post area (message icon and subject permalink), and the footer bar (an icon and a "thanked by" profile link). The first post with a thanker link reads as a three-card grid. hasFollowingProse only counts <p> text, and SMF post bodies are <br>-separated text in divs, so it does not stop the removal, and removeTrailingSiblings then takes the rest of the thread.

The change: a removal target that has a sibling with the same tag and the same child and grandchild tag layout is skipped, since that is one entry in a run of repeated items (posts, comments) and not a trailing block. Classes are ignored because they can be hashed. It uses continue, so a real card grid later in the page is still checked. The tradeoff, also in the code comment: a real related block that sits beside a sibling with the same layout is now kept. That leaves clutter in rather than dropping content.

I looked at two narrower options first. Requiring the cards to share a layout does not separate them here, since postarea and moderatorbar have the same one-level shape. Widening hasFollowingProse to count div text would still drop the last post when that post is the one that matches.

The new fixture content-patterns--forum-thread-post-columns.html is an anonymized SMF-style thread with 11 posts. Without the src change it keeps 3 of 10 replies and the fixture test fails. With it, all 10 are kept. npm test and npm run test:jsdom both pass with no existing expected output changed. On the original eevblog page all 19 replies are kept.

In an SMF-style thread, a post's poster sidebar, message area and footer
bar can each hold an icon and a link, so the headingless card-grid rule
matched a single post's wrapper as a related post grid and removed that
post and every later post as trailing content.

Posts in a thread repeat one layout, so skip a removal target that has a
sibling with the same tag and child layout.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant