Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
20.81k stars 344 forks source link

Feature request: More granular diffs in (X)HTML #312

Open acabal opened 2 years ago

acabal commented 2 years ago

At Standard Ebooks, we work with ebooks in XHTML format. Since our books are typically prose novels, a single line of source code can be a very long <p> element, for example:

<p>To which Don Quixote replied, “Thou must take notice, brother Sancho, that this adventure and those like it are not adventures of islands, but of crossroads, in which nothing is got except a broken head or an ear the less: have patience, for adventures will present themselves from which I may make you, not only a governor, but something more.”</p>

We often make small changes to lines, like adding or removing a single character to fix a typo. In a typical diff situation, this is hard to see because the line is so long and a "change" highlights the entire line. This also appears to be the case with Difftastic, in which changing one character in a long <p> will highlight the entire contents of the element, instead of just the addition/deletion.

In regular git, we usually have to invoke git diff -U0 --word-diff-regex=. to get the kind of diff that's actually helpful, but that's not syntax-aware or very pretty. Would it be possible to have Difftastic highlight changes within (X)HTML text nodes in a more granular manner?

acabal commented 2 years ago

Possibly related to #178