dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.32k stars 358 forks source link

🚀 output using html <ins> and <del> tags #1703

Open frivoal opened 1 month ago

frivoal commented 1 month ago

When the old and new files being compared are HTML (or markdown), it would be convenient to have the ability to opt into a mode where the output is the original file, with the differences marked with the html <ins> and <del> elements.

For example: Old:

<!doctype html>
    <p>Hello wrodl.

New:

<!doctype html>
    <p>Hello world.

Output:

<!doctype>
    <p>Hello <del>wrodl</del><ins>world</ins>.

Since git-delta already has the ability to detect word-level diff, it seems this could be achievable.

The reason why this would be useful is that when making changes to human readable documents, the source diff isn't always the most user-friendly, and a rendered diff can make life much easier for reviewers. There already exist a number of standalone htmldiff tools, but:

I guess the biggest challenge is that this would need some degree of syntax awareness, to avoid injecting tags in the middle of html attributes or other invalid locations.