SwiftDiff

master

Diff text in Swift
cyber-fun/SwiftDiff

SwiftDiff

SwiftDiff is a (partial) port of the Google Diff, Match and Patch Library (google-diff-match-patch) to Swift. The Google Diff, Match and Patch Library was originally written by Neil Fraser.

So far only the diff algorithm has been ported. It allows comparing two blocks of plain text and efficiently returning a list of their differences. It supports detecting in-line text differences.

SwiftDiff was updated to Swift 5 and SPM 5.1 by Cyberfun

License

SwiftDiff is licensed under the Apache License 2.0 – see the LICENSE file for details.

The original Google Diff, Match and Patch Library is also licensed under the same license and Copyright (c) 2006 Google Inc.

Usage

diff(text1: "The quick brown fox jumps over the lazy dog.", 
     text2: "That quick brown fox jumped over a lazy dog.")
[
  .equal("Th"),
  .delete("e"),
  .insert("at"),
  .equal(" quick brown fox jump"),
  .delete("s"),
  .insert("ed"),
  .equal(" over "),
  .delete("the"),
  .insert("a"),
  .equal(" lazy dog.")
]

Description

  • Swift Tools 5.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Mar 31 2024 21:32:22 GMT-0900 (Hawaii-Aleutian Daylight Time)