How can I implement a diff function, such as Stack Overflow’s question revision history?
How can I implement a diff function, such as Stack Overflow’s question revision history?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have here a javascript example of the implementation of a diff algorithm.
Based on:
P. Heckel, A technique for isolating differences between files Comm. ACM, 21, (4), 264–268 (1978).
The implementation, itself, has two functions, one of which is recommended for use:
This method takes two strings and calculates the differences in each. The final result is the ‘newFile’ marked up with HTML (to signify both deletions from the oldFile and additions to the newFile).