Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

[JavaScript] diff_prettyHtml highlight leading/trailing space difference #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

54mu3l
Copy link

@54mu3l 54mu3l commented Jun 2, 2023

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:
image

Now with this pull requests it looks like this:
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant