<html>
<body>
<script src="diff_match_patch.js"></script>
<script>
var dmp = new diff_match_patch();
// var diff = dmp.diff_main('Hello World.', 'Goodbye World.');
let a = 'Hello World.' ;
let b = 'Goodbye World.' ;
var diff = dmp.patch_make(a,b);
// Result: [(-1, "Hell"), (1, "G"), (0, "o"), (1, "odbye"), (0, " World.")]
// dmp.diff_cleanupSemantic(diff);
// Result: [(-1, "Hello"), (1, "Goodbye"), (0, " World.")]
let dif = dmp.patch_apply(diff,a)
alert(dif);
</script>
</body>
</html>
网友评论