Wilfred / difftastic

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

Provide an HTML output option #45

Open Wilfred opened 3 years ago

Wilfred commented 3 years ago

This would be valuable for exploring large files, as well as regression testing.

Milo123459 commented 2 years ago

Hey! Anyway I can help out with this issue?

Mephistophiles commented 2 years ago

Is the commit f442efa adding the ability to output html? Or is it a typo in the commit message?

Niek commented 2 years ago

See: https://github.com/Wilfred/difftastic/pull/158 The JSON output can be used to generate a HTML page.

Wilfred commented 2 years ago

Argh, commits from git subtrees are closing issues in this repo. This isn't done yet.

Milo123459 commented 2 years ago

Haha, are there any updates on this? I see you can generate HTML from the JSON, but is there a guide on it or something?

nazarewk commented 1 year ago

@Milo123459 see my example in Python

@Wilfred I have found a few shortcomings of the json output preventing it's use in real-life. The output itself is not enough to rebuild a diff without:

  1. reading source files, tracking down line locations and extracting their content,
  2. sorting diff entries properly (they are unordered within a chunk/block!)
rgeraskin commented 3 weeks ago

workaround:

  1. save stdout with ansi colors difft …… | tee colored_diff_with_ansi_codes
  2. use ansi2html cat colored_diff_with_ansi_codes | ansi2html > diff.html
Milo123459 commented 3 weeks ago

I think providing an extension that could utilise difftastic on GitHub would be useful. I'm not sure if your workaround would work for that though