GithubHelp home page GithubHelp logo

Comments (9)

fraballi avatar fraballi commented on May 26, 2024 1

Many thanks, already accomplished all the objectives. Made a test project and compared git diff output with the article on GNU diff command (dates weren't there).

Next, using git-diff superset library with a prepended mocked header as:

index 0001fb1..c00002e 000003
--- a/collection.json
+++ b/collection.json
@@ -1,4 +1,4 @@
-{"status":true,"collection":{"item":[{

Appreciate all the help and resources posted. Great project by the way ;-)

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

Can you provide and example of what is your changes content?
If you want to just inject something in the dom you can use Diff2HtmlUI directly

Keep in mind that this repository is just the CLI, if you want to use the parser and generator directly you should check Diff2Html

from diff2html-cli.

fraballi avatar fraballi commented on May 26, 2024

I need both: parser and htmlUI, for sending an email with a Diff2Html file attached (zipped html) but also replacing message body content with html output.

Tried this also without success:
package.json

dependencies:{
"git-diff": "^2.0.6",
"diff2html": "^3.2.0"
}

index.js

   const gitDiff = require('git-diff');
   const diff2html = require('diff2html');
 
   // Git-Diff Basic Example
   const oldStr = 'fred\nis\nfunny\n'
   const newStr = 'paul\nis\nfunny\n'
   const diff2 = gitDiff(oldStr, newStr, { forceFake: true })

  // diff2:   '-fred\n+paul\n is\n funny\n'

   const parsed = diff2html.parse(diff2);   // [], length = 0

  // Nothing to pass to:  
   const html = diff2html.html(parsed);

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

diff2 is not a valid unified diff (which is a subset of git diff)
Check https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html#Example-Unified for more details.

from diff2html-cli.

fraballi avatar fraballi commented on May 26, 2024

Here is an example, checking postman collections. Could only put a fragment, due to privacy issues. ;-)
Should this format work, also using git-diff npm? Kindly, can suggest any npm superset library, for comparing text instead of files as: git diff does?

@@ -1,4 +1,4 @@
-{"status":true,"collection":{"item":[{
...

Same output for:

const parsed = diff2html.parse(diff2);   // [], length = 0

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

That still seems invalid.
The minimum you need is the names of the old file and the new file prefixed by --- and +++ respectively, then you have the hunks that start with the line numbers @@ and then the changed lines prefixed with , -, +.

You are at least missing the file names.

from diff2html-cli.

fraballi avatar fraballi commented on May 26, 2024

So, the solution is aimed to files (git diff) instead of text-only.
Then, could add dummy section to the top:

--- dummy1	2002-02-21 23:30:39.942229878 -0800
+++ dummy2	2002-02-21 23:30:50.442260588 -0800
@@ -1,4 +1,4 @@
-{"status":true,"collection":{"item":[{
...

Which time format is: 2002-02-21 23:30:50.442260588 -0800?
Perhaps:

Format Example
yyyy-MM-dd HH:mm:ss.SSSZZZZ 2017-03-12 13:11:34.222-0700

From: Timestamps, Time Zones, Time Ranges, and Date Formats

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

So, the solution is aimed to files (git diff) instead of text-only.

As explained in the readme this tool supports parsing the unified diff format which git diff builds over.

The data format is described here although I don't think it is used for anything.

from diff2html-cli.

rtfpessoa avatar rtfpessoa commented on May 26, 2024

Glad you got it working

from diff2html-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.