Repository navigation
Match moved elements instead of reporting them as changed - #8
Merged
Merged
Conversation
Element keys are structural, so adding a section renumbered everything after it and check compared the new section's text with the old next section. On fynepdf.com/developers that gave 5 false "wraps differently" results. check now pairs elements in this order: named keys (data-wrapguard or own id) by name; the rest in page order by text, as a longest common subsequence, so insertions and removals shift nothing and repeated text pairs in order; leftover same text out of order as moved; same key with new text as a copy edit. Text that only moved is listed under "Moved, same text" with --verbose and in the Markdown details, and never fails the check. The same /developers case now reports 7 new, 11 moved, no wrapping changes.
Merged
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.
The problem
Found by using wrapguard on fynepdf.com's
/developerspage (fynepdf-frontend#298). Element keys are structural (main > section[9] > h2), so adding a section renumbered every section after it, andcheckcompared the new section's text with the old next section:None of them did.
The fix
checknow decides which saved element each scanned element is compared with, in this order (pairElementsinsrc/diff.ts):data-wrapguardor the element's own id) by nameWhatever is left is new or gone. Text that only moved is listed as "Moved, same text" with
--verboseand in the Markdown details, counted in the summary line only when there is any, and never fails the check. Very large pages (over 16M old × new elements) skip step 2 and fall back to steps 3 and 4.Checked
test/diff.test.ts: section inserted above, moved and rewrapped (still a failure), repeated text after an insertion, section removed from the middle, copy edit in place, named key kept when another element had its new text, text jumping past other content/developersbefore-snapshot against the page with the new section now gives✓ No wrapping changes, with 7 new and 11 moved (the call-to-action, one section down)Not released. This would go out as 0.2.0 (new
movedfield in the JSON output andDiffResult).