Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTML entity replacements for tab and space characters #7

Conversation

LaurentAerens
Copy link

@LaurentAerens LaurentAerens commented Feb 20, 2024

diff_prettyHtml currently doesn't highlight leading/trailing space differences. Because spaces in HTML aren't visible.

This pull request changes that.

Instead of

<ins style="background:#e6ffe6;"> </ins>

diff_prettyHtml now returns

<ins style="background:#e6ffe6;">&nbsp;</ins>

resulting in differences with leading/training spaces being visible in HTML.

Example:
When we compare "Test" and "Test " (notice the second string doesn't equal the first string since it has a trailing space).

var diff = dmp.diff_main("Test", "Test "); // this results in the following diff: [[0, 'Test'], [1, ' ']]

Previously looked like this:

242906142-5ebd2764-0129-49f0-b3c0-ec77319316f3

Now with this pull requests it looks like this:

242906167-f99add6a-79c2-42f5-8286-fa043903b9f5

Note: this issue also seems to be present in the JavaScript implementation: google#144

@LaurentAerens
Copy link
Author

Is there any potential this PR could get a review?

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