trevorcampbell / website_diff

MIT License
2 stars 1 forks source link

Separate entire changed lines more clearly #26

Open joelostblom opened 2 months ago

joelostblom commented 2 months ago

This source diff:

image

is represented as this rendered diff:

image

I think the source diff is clearer to read in this case, given that the change has resulted in a completely new sentence rather than just word-level modifications to the same sentence. Not sure how easy this is to split out on the render level, but it could be clearer to try to do what the source diff does here and mark one entire sentence as deleted and then one entire sentence as added instead of doing it word by work.

Live here for a bit: https://joelostblom.github.io/viz-oer/diff29/index.html

trevorcampbell commented 2 months ago

Yeah, it's a known behaviour. I don't mind it for now, since the big win of website_diff is to catch diffs that aren't obvious from the source files (in your example, it's already obvious there). But it would be nice to collapse these tiny little piecemeal insertion/deletion elements.

For posterity, the source of the diff looks like:

image

trevorcampbell commented 2 months ago

@briank-git does the diff engine have some flags that let us tune that? If not, we can always just check for sequences of <ins> and <del> elements that just contain text (no internal elements) and merge those, as they're commutative.

joelostblom commented 2 months ago

Yes, agree this is a minor convenience and that the big win is to notify me of things I wouldn't see otherwise :+1:

briank-git commented 2 months ago

@trevorcampbell No the diff engine doesn't have those flags, its pretty bare bones.

trevorcampbell commented 2 months ago

Understood. Yeah in theory, I think that we can actually merge any sibling <ins> elements and <del> elements in the tree (even if they contain child elements themselves), so maybe that's an easy "post-processing" step that we can do at some point. Not urgent though