Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
Glad you got it working
from diff2html-cli.
Related Issues (20)
- ignore.map is not a function HOT 2
- -M flag exists? HOT 1
- Dependency update? HOT 3
- Unescaped broken HTML in the output HOT 6
- Selecting an output file is not overriding the preview open HOT 1
- ENOBUFS error when comparing large commits HOT 3
- "--ig" argument leads to git diff error HOT 7
- diff2html is missing file content toggle HOT 1
- --title option not working HOT 2
- miss-align when show some diff file HOT 4
- Still running out of heap memory while allowing node 60GB HOT 4
- '--renderNothingWhenEmpty' didn't work when using 'stdin' as input HOT 1
- Impossible to create a diff from file – 5.2.6
- Can't run diff2html-cli on linux docker container HOT 1
- Cannot see diff on specials characters (eg ^M) HOT 1
- Not able to run diff2html-cli on both windows and wsl HOT 4
- feature: add colorScheme arg
- Feature request: line anchor
- The stack overflow exception is displayed when the file exceeds 14M
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diff2html-cli.