Turns out there are different diff algorithms you can use. Here's the shortest friendly example I can find: https://stackoverflow.com/a/36551123/509706