Cloudey.Different
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Cloudey.Different --version 1.0.0
NuGet\Install-Package Cloudey.Different -Version 1.0.0
<PackageReference Include="Cloudey.Different" Version="1.0.0" />
paket add Cloudey.Different --version 1.0.0
#r "nuget: Cloudey.Different, 1.0.0"
// Install Cloudey.Different as a Cake Addin #addin nuget:?package=Cloudey.Different&version=1.0.0 // Install Cloudey.Different as a Cake Tool #tool nuget:?package=Cloudey.Different&version=1.0.0
🔀 Different
Robust, easy-to-use diff and patch library for comparing and synchronising text with zero dependencies
What is this
Different provides extension methods for creating and applying diffs and patches for plain text.
It uses the same robust algorithms and logic as commonly seen used with git repositories, wrapped in a readable, easy-to-use library.
How to use
🔀 Diff
Get the differences between two texts
string from = "Hello!";
string to = "Hallo?";
List<Diff> diffs = from.Diff(to);
Result
{
{Operation.EQUAL, "H"},
{Operation.DELETE, "e"},
{Operation.INSERT, "a"},
{Operation.EQUAL, "llo"},
{Operation.DELETE, "!"},
{Operation.INSERT, "?"}
}
Details: diff-match-patch#diff_main
✨ Semantic diff
Get the differences between two texts, optimised for human-readability
Two unrelated texts can contain many coincidental matches. This can make the diff hard to understand for humans, despite being the optimal result. A semantic diff rewrites the diff to be more legible and easier to understand.
string from = "Computer";
string to = "Mouse";
List<Diff> diffs = from.SemanticDiff(to);
Result
{
{Operation.DELETE, "Computer"},
{Operation.INSERT, "Mouse"},
}
Details: diff-match-patch#diff_cleanupSemantic
⏱ Efficient diff
Get the differences between two texts, optimised for machine processing
Applying a large number of small diffs can take drastically longer to process in some scenarios than a small number of larger diffs. An efficient diff rewrites the diff to eliminate and combine tiny diffs into larger ones based on an edit cost heuristic. The result is often similar to a semantic diff, but not always.
string from = "Computer";
string to = "Mouse";
List<Diff> diffs = from.EfficientDiff(to);
Result
{
{Operation.DELETE, "Computer"},
{Operation.INSERT, "Mouse"},
}
Details: diff-match-patch#diff_cleanupEfficiency
📐 Levenshtein distance
Measure the Levenshtein distance of a diff in terms of changed characters
The minimum value is 0, meaning the strings are equal. The maximum value is the length of the longer string.
string from = "Hello!";
string to = "Hallo?";
List<Diff> diffs = from.Diff(to);
diffs.Levenshtein();
Result
2 // e -> a, ! -> ?
Details: diff-match-patch#diff_levenshtein
🔡 Visualise diffs as HTML
Get an HTML representation of a diff
This can be used to visualise diffs in a human-readable way.
string from = "Hello!";
string to = "Hallo?";
List<Diff> diffs = from.Diff(to);
diffs.Html();
Result
<span>H</span>
<del style="background:#ffe6e6;">e</del>
<ins style="background:#e6ffe6;">a</ins>
<span>llo</span>
<del style="background:#ffe6e6;">!</del>
<ins style="background:#e6ffe6;">?</ins>
Details: diff-match-patch#diff_prettyHtml
License
Licensed under Apache 2.0.
Copyright © 2021 Cloudey IT Ltd
Cloudey® is a registered trademark of Cloudey IT Ltd. Use of the trademark is NOT GRANTED under the license of this repository or software package.
For diff-match-patch library contained within repository and distributed code: Copyright 2018 The diff-match-patch Authors. https://github.com/google/diff-match-patch Modifications were made to the diff-match-patch library (licensed under Apache 2.0) by the authors of this package (Cloudey)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.