I would like to get the differences (string deleted and string added) between two HTML Strings. The function of the diff function has to give result as follows:
String html1 = "<h1>foo foo </h1>";
String html2 = "<h1>foo baar </h1>";
private String diff(String html1, String html2){
...
// diff method should return following:
return "<h1>foo <span class = "deleted">foo</span> <span class = "added">baar </span> </h1>";
}
I tried diff_match_patch but it has Problem with html tags. Example:
String html1 = "<ol><li>foo</li><li>baar</li></ol>"
String html2 = "<ol><li>AA</li></ol>"
diff_match_patch(html1, html2) gives the following diff string:
<ol>
<li>AA<del style="background:#ffe6e6;"></li>
<li>BB</del>
</li>
</ol>
it should be:
<ol>
<li>AA</li>
<del style="background:#ffe6e6;"><li>BB</del>
</li>
</ol>