Skip to content

feat(xml-diff): add XML diff tool - #1840

Open
bruno-b-martins wants to merge 4 commits into
CorentinTh:mainfrom
bruno-b-martins:feat/xml-diff-tool
Open

feat(xml-diff): add XML diff tool#1840
bruno-b-martins wants to merge 4 commits into
CorentinTh:mainfrom
bruno-b-martins:feat/xml-diff-tool

Conversation

@bruno-b-martins

@bruno-b-martins bruno-b-martins commented Aug 8, 2026

Copy link
Copy Markdown

#1839

Summary

  • Adds an XML diff tool that compares two pasted XML documents and highlights differences, mirroring the existing JSON diff tool's UI
  • XML is parsed with a native DOMParser-based normalizer instead of xml-js: attributes become @name keys, text-only leaves collapse to plain strings, and repeated elements become arrays — avoiding xml-js's ambiguous "single element vs. array" compact format.
  • Adds a reconciliation step (xml-diff.reconcile.ts) that coerces mismatched single/repeated element shapes into arrays before diffing, so an element going from one occurrence to several diffs cleanly (e.g. "item added: B") instead of producing a garbled type-mismatch diff.
  • Also includes a small unrelated grammar fix in the README and a .gitignore entry for .pnpm-store.

Test plan

  • pnpm run typecheck passes
  • pnpm lint passes with no new errors/warnings
  • pnpm run test:unit passes (all 36 test files, including new parser/reconciliation/model unit tests)
  • pnpm run build succeeds
  • Manually verified in a running dev server: attribute/text diffs, unchanged-XML detection ignoring insignificant whitespace, "only show differences" filter, and the single-vs-repeated-element cardinality fix

Generated with Claude 🤖

bruno-b-martins and others added 4 commits August 8, 2026 23:11
Compare two pasted XML documents and highlight the differences, mirroring
the JSON diff tool's UI and diff engine. XML is parsed with a native
DOMParser-based normalizer (attributes as @name, text-only leaves as plain
strings) instead of xml-js, and a reconciliation step coerces mismatched
single/repeated element shapes into arrays before diffing so a repeated
element compares cleanly instead of producing a garbled type-mismatch diff.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Fixes a SonarQube quality gate failure (32.3% duplication on new code,
required <= 3%) caused by xml-diff.models.ts, xml-diff.types.ts and
diff-viewer.models.tsx being near-verbatim copies of json-diff's own
files. The diff algorithm and viewer are format-agnostic, so xml-diff
now imports diff() and DiffRootViewer directly from json-diff instead
of maintaining a parallel copy, mirroring the existing precedent of
xml-to-json importing isValidXML from xml-formatter.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

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