htmldiff.net
htmldiff.net copied to clipboard
<ins class='mod'> without closing tag
If i compare texts with special tags like "sup" which was added (or deleted), the differ adds an ins-tag without closig it.
Here is a simple UT, that shows this behavior
[Test]
public void WrongResultWithSpecialTag()
{
const string oldText = @"<div class=""dumb"">Thiis a text without any sup-tags and other special things</div>";
const string newText = @"<div class=""dumb"">Thiis a text <sup>1</sup>without any sup-tags and other special things</div>";
var expectadText = @"<div class=""dumb"">Thiis a text <sup><ins class='diffins'>1</ins></sup>without any sup-tags and other special things</div>";
Debug.WriteLine("Old text: " + oldText);
Debug.WriteLine("New text: " + newText);
Debug.WriteLine("");
Debug.WriteLine("Expected Diff: " + expectadText);
var result = new global::HtmlDiff.HtmlDiff(oldText, newText).Build();
Debug.WriteLine("");
Debug.WriteLine("Actual Diff: " + result);
//The Result is "<div class=""dumb"">Thiis a text <sup><ins class='mod'><ins class='diffins'>1</ins></sup>without any sup-tags and other special things</div>"
Assert.AreEqual(expectadText, result);
}
I have noticed similar behavior. I don't know if it is related to this (wrong) regexp in Uitls.cs:
private static Regex openingTagRegex = new Regex("^\\s*<[^>]+>\\s*$", RegexOptions.Compiled);
that match both opening and closing tag or to the problems of stack...