Click or drag to resize

DiffMatchPatch Methods

The DiffMatchPatch type exposes the following members.

Methods
  Name Description
Protected method DiffBisect

Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff.

See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.

Protected method DiffCharsToLines Rehydrate the text in a diff from a string of line hashes to real lines of text.
Public method DiffCleanupEfficiency Reduce the number of edits by eliminating operationally trivial equalities.
Public method DiffCleanupMerge Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality.
Public method DiffCleanupSemantic Reduce the number of edits by eliminating semantically trivial equalities.
Public method DiffCleanupSemanticLossless Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. e.g: The cat came. -> The cat came.
Protected method DiffCommonOverlap Determine if the suffix of one string is the prefix of another.
Public method DiffCommonPrefix Determine the common prefix of two strings.
Public method DiffCommonSuffix Determine the common suffix of two strings.
Public method DiffFromDelta Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, compute the full diff.
Protected method DiffHalfMatch Do the two texts share a Substring which is at least half the length of the longer text? This speedup can produce non-minimal diffs.
Public method DiffLevenshtein Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
Protected method DiffLinesToChars Split two texts into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
Public method DiffMain(String, String) Find the differences between two texts. Run a faster, slightly less optimal diff. This method allows the 'checklines' of DiffMain() to be optional. Most of the time checklines is wanted, so default to true.
Public method DiffMain(String, String, Boolean) Find the differences between two texts.
Public method DiffPrettyHtml Convert a Diff list into a pretty HTML report.
Public method DiffText1 Compute and return the source text (all equalities and deletions).
Public method DiffText2 Compute and return the destination text (all equalities and insertions).
Public method DiffToDelta Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation.
Public method DiffXIndex loc is a location in text1, compute and return the equivalent location in text2. e.g. "The cat" vs "The big cat", 1->1, 5->8
Public method Static member EncodeURI Encodes a string with URI-style % escaping. Compatible with JavaScript's encodeURI function.
Public method Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public method GetHashCode Serves as the default hash function.
(Inherited from Object)
Public method GetType Gets the Type of the current instance.
(Inherited from Object)
Protected method MatchAlphabet Initialize the alphabet for the Bitap algorithm.
Protected method MatchBitap Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. Returns -1 if no match found.
Public method MatchMain Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if no match found.
Protected method MemberwiseClone Creates a shallow copy of the current Object.
(Inherited from Object)
Protected method PatchAddContext Increase the context until it is unique, but don't let the pattern expand beyond MatchMaxBits.
Public method PatchAddPadding Add some padding on text start and end so that edges can match something. Intended to be called only from within PatchApply.
Public method PatchApply Merge a set of patches onto the text. Return a patched text, as well as an array of true/false values indicating which patches were applied.
Public method PatchDeepCopy Given an array of patches, return another array that is identical.
Public method PatchFromText Parse a textual representation of patches and return a List of Patch objects.
Public method PatchMake(ListDiff) Compute a list of patches to turn text1 into text2. text1 will be derived from the provided diffs.
Public method PatchMake(String, ListDiff) Compute a list of patches to turn text1 into text2. text2 is not provided, diffs are the delta between text1 and text2.
Public method PatchMake(String, String) Compute a list of patches to turn text1 into text2. A set of diffs will be computed.
Public method PatchMake(String, String, ListDiff) Obsolete.
Compute a list of patches to turn text1 into text2. text2 is ignored, diffs are the delta between text1 and text2.
Public method PatchSplitMax Look through the patches and break up any which are longer than the maximum limit of the match algorithm. Intended to be called only from within PatchApply.
Public method PatchToText Take a list of patches and return a textual representation.
Public method ToString Returns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
  Name Description
Public Extension Method GetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension Method GetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
See Also