0

I have a database which stores sequential versions of a text file. What I would like to do is allow the user to call up any two historical files (e.g version 1 And version 4) and compare them for differences:

  1. Spelling changes
  2. New words / new sentences / new paragraphs
  3. Moved paragraphs
  4. Etc

Basically an online GIT but for text files not code.

I figure JavaScript is probably the best approach and I presume that there must be an open source library but I simply cannot find one.

Any assistance appreciated.

DrBorrow
  • 950
  • 12
  • 24
  • Have a look at [Mergely](http://www.mergely.com/doc), it does a wonderful job – Nico Haase Dec 05 '17 at 21:26
  • Thank you. I have looked at mergely but it doesn’t seem to do a great job at managing moved paragraphs - do I need to ha file that separately? – DrBorrow Dec 05 '17 at 21:30

1 Answers1

0

If you are running under linux, you could install diff, save both files in temp files, then compare them using the shell_exec command.

For example

$tmp1 = 'myfile.txt';
$tmp2 = 'myfile2.txt';    
$output = shell_exec('diff -y {$tmp1} {$tmp2}');

Look at man diff for an option that suits your needs.

Bernz
  • 171
  • 3