Skip to content

fix(diff): preserve HTML nesting and word-separating whitespace in structural diff - #112

Merged
phine-apps merged 1 commit into
mainfrom
fix/structural-diff-html-integrity
Nov 25, 2026
Merged

phine-apps merged 1 commit into
mainfrom
fix/structural-diff-html-integrity

Conversation

@phine-apps

Copy link
Copy Markdown
Owner

Summary

  • Fix cleanupUnbalancedDiffTags in src/markdown/structuralDiff.ts to remove whitespace-only <ins>/<del> tags only at block boundaries, preserving word-separating whitespace (e.g. soft line breaks) and collapsing adjacent opposite-polarity whitespace pairs in running text to a single space.
  • Fix fixInvalidNesting in src/markdown/structuralDiff.ts:
    • Step 1: Use getTagDepth so inline closing tags opened inside <ins>/<del> (e.g. <ins><code>a</code></ins>) are not moved outside the diff tag.
    • Step 3: Guard against corrupting preceding inline tags when another inline tag is inside <ins>/<del>.
    • Step 4: Replace non-greedy blockRegex with findClosing()-based promoteBlockDiffs so nested block-like containers are not cut short at inner close tags and non-promoted blocks still balance diff tags at block boundaries.
  • Add unit tests in src/test/unit/structuralDiffIntegrity.test.ts and update fixtures/expected/comprehensive.html.
  • Stabilize overlay screenshot capture in src/test/visual/mapping_proof.test.ts using boundingBox() + page.screenshot({ clip }).

Verification

  • pnpm run compile && pnpm run lint && npx mocha ./out/test/unit/**/*.test.js (315 passing)
  • Docker Playwright: src/test/visual/mapping_proof.test.ts and src/test/visual/vrt.test.ts (comprehensive-v1-v2 - split-light) passed

@phine-apps
phine-apps merged commit 8ecd248 into main Nov 25, 2026
3 checks passed
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