Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Ensure equalities processed via new processEqualities hook (Fixes #219)#224

Merged
wumpz merged 1 commit intojava-diff-utils:masterfrom
tusharsoni52:fix-219-option3
Dec 10, 2025
Merged

Fix: Ensure equalities processed via new processEqualities hook (Fixes #219)#224
wumpz merged 1 commit intojava-diff-utils:masterfrom
tusharsoni52:fix-219-option3

Conversation

@tusharsoni52
Copy link
Contributor

Summary

This PR introduces a new extension point,processEqualities(), insideDiffRowGenerator to address the HTML-escaping issue described in#219.

Previously, equal (unchanged) segments were passed through HTML normalization only once.
Because< and> were normalized to&amp;lt; and&amp;gt;, equalities that began with& caused incorrect inline diff grouping (e.g.,&amp;lt; vs&amp;gt;). This produced invalid HTML wheninlineDiffByWord(true) was used.

What This PR Changes

✔ Adds a new protected hook:

protected String processEqualities(String text)

✔ All equality chunks now pass through this hook before becomingDiffRow(Tag.EQUAL, ...).
✔ Default behavior is no modification (fully backward compatible).
✔ Users can override this hook to customize HTML or text transformations after diffing, solving the core issue.

Why this Fix Works

The problem in#219 occurs because the diff logic comparesnormalized text, but the final output does not normalizeequal segments the same way as diffs.

By exposingprocessEqualities(), we give users a consistent post-diff transformation path.
This ensures that equal text is handled symmetrically to diffed text and prevents HTML-breaking cases like&amp;lt; /&amp;gt; being partially diffed.

Backward Compatibility

  • Existing behavior is preserved.
  • No breaking API changes.
  • The feature is opt-in — users override it only if needed.

Tests Included

✔ AddedDiffRowGeneratorEqualitiesTest
✔ Verifies that:

Fixes

Fixes#219

…rocessed for unchanged lines (Fixesjava-diff-utils#219)- Introduces a new protected method `processEqualities(String)` in DiffRowGenerator- Builder exposes `.processEqualities(Function<String,String>)`- Equal (unchanged) lines now invoke processEqualities()- Inline diffs remain unchanged (as expected in Option 3)- Added new test suite DiffRowGeneratorEqualitiesTest- Updated documentation and Javadoc for new extension point-Fixesjava-diff-utils#219 (HTML escaping issue when inline diff by word)
@wumpzwumpz merged commit696edc4 intojava-diff-utils:masterDec 10, 2025
4 checks passed
@wumpz
Copy link
Collaborator

thx for your pr

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Line normalization before diff

2 participants

@tusharsoni52@wumpz

[8]ページ先頭

©2009-2026 Movatter.jp