-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught TypeError: diffInput.replace is not a function #202
Comments
@rickywu what is the value of |
@rtfpessoa copy the code save as html and open it in browser, you can see the two texts and d is the diff from these two input box |
@rickywu if it would be that easy I could have done it. Time is always short to help. Still, after a quick look in the documentation of google/diff-match-patch it does not seem to provide a unified diff which is the required input for diff2html. You need to generate the output from other tool probably. Check #198 as an alternative. or look for another diff tool in npmjs.org |
Then patchToText can be used for diff2html |
That should work |
This was a great start but was not enough to get it fully working because Git diff seems to require having the 2 files being diffed at the start of the diff header. So with that in mind, I was able to get it working by prefixing the let patchToText = `diff --git a/file.txt b/file.txt
--- a/file.txt
+++ b/file.txt
`;
patchToText += dmp.patch_make(text1Ref.value, diffs); HTML PreviewEDIT in the end, I found this Stack Overflow Create unified diff text for diff2html in browser and the answer to use jsdiff works a lot better and it's super short. const diff = JSDiff.createTwoFilesPatch('file', 'file', text1Ref.value, text2Ref.value);
const diffHtml = html(diff, { drawFileList: true, matching: 'lines', outputFormat: 'side-by-side' }); which now gives the following, it's so much better with line number and everything :) |
Seems this issue closed 3 years ago but I still got this error,
download diff_match_patch.js from https://github.com/google/diff-match-patch and change path if needed
try this sample
The text was updated successfully, but these errors were encountered: