From 869351ffbf29192512c47e429b2af24155222b76 Mon Sep 17 00:00:00 2001 From: Marcelo Neves Date: Fri, 12 Feb 2016 12:43:54 -0200 Subject: [PATCH 1/4] =?UTF-8?q?Adicionado=20propriedade=20para=20ignorar?= =?UTF-8?q?=20delete=20ou=20n=C3=A3o=20marcar=20o=20insert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HtmlDiff/Diff.cs | 23 +++++++++++++++++++++-- HtmlDiff/HtmlDiff.csproj | 7 +++++++ HtmlDiff/HtmlDiffPublicPrivate.snk | Bin 0 -> 596 bytes 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 HtmlDiff/HtmlDiffPublicPrivate.snk diff --git a/HtmlDiff/Diff.cs b/HtmlDiff/Diff.cs index 22dfdcd..a74c661 100644 --- a/HtmlDiff/Diff.cs +++ b/HtmlDiff/Diff.cs @@ -16,8 +16,7 @@ public class HtmlDiff private readonly StringBuilder _content; private string _newText; - private string _oldText; - + private string _oldText; private static Dictionary _specialCaseClosingTags = new Dictionary(StringComparer.OrdinalIgnoreCase) { @@ -83,6 +82,16 @@ public class HtmlDiff /// public double OrphanMatchThreshold { get; set; } + /// + /// If true all deleted texts are not formatted. + /// + public bool IgnoreDelete { get; set; } + + /// + /// If true all inserted texts are not formatted. + /// + public bool IgnoreInsert { get; set; } + /// /// Initializes a new instance of the class. /// @@ -181,11 +190,21 @@ private void ProcessReplaceOperation(Operation operation) private void ProcessInsertOperation(Operation operation, string cssClass) { List text = _newWords.Where((s, pos) => pos >= operation.StartInNew && pos < operation.EndInNew).ToList(); + + if (IgnoreInsert) + { + _content.Append(string.Join("", text.ToArray())); + return; + } + InsertTag("ins", cssClass, text); } private void ProcessDeleteOperation(Operation operation, string cssClass) { + if (IgnoreDelete) + return; + List text = _oldWords.Where((s, pos) => pos >= operation.StartInOld && pos < operation.EndInOld).ToList(); InsertTag("del", cssClass, text); } diff --git a/HtmlDiff/HtmlDiff.csproj b/HtmlDiff/HtmlDiff.csproj index 0649a11..ada6a1b 100644 --- a/HtmlDiff/HtmlDiff.csproj +++ b/HtmlDiff/HtmlDiff.csproj @@ -36,6 +36,12 @@ prompt 4 + + true + + + HtmlDiffPublicPrivate.snk + @@ -66,6 +72,7 @@ Designer +