美文网首页react-native
diff_match_patch.js

diff_match_patch.js

作者: 猪猪9527 | 来源:发表于2018-03-29 11:35 被阅读77次
    <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>
    
    

    相关文章

      网友评论

        本文标题:diff_match_patch.js

        本文链接:https://www.haomeiwen.com/subject/fdlmcftx.html