Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: falsebrings all 19 back.debug.removalsshows the chain: reply #9 is removed as "related post cards", itshr.post_separatoras "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 animgplus a heading ora[href]. One SMF post'sdiv.post_wrapperhas 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.hasFollowingProseonly counts<p>text, and SMF post bodies are<br>-separated text in divs, so it does not stop the removal, andremoveTrailingSiblingsthen 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
postareaandmoderatorbarhave the same one-level shape. WideninghasFollowingProseto 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.htmlis an anonymized SMF-style thread with 11 posts. Without thesrcchange it keeps 3 of 10 replies and the fixture test fails. With it, all 10 are kept.npm testandnpm run test:jsdomboth pass with no existing expected output changed. On the original eevblog page all 19 replies are kept.