Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 1.58 KB

README.md

File metadata and controls

34 lines (27 loc) · 1.58 KB

Diff Match Patch for Nim

This is the WIP Nim implementation of Neil Fraser's Diff Match and Patch for Google Docs.

From the original description:

The Diff Match and Patch libraries offer robust algorithms to perform the operations required for synchronizing plain text.

  1. Diff:
    • Compare two blocks of plain text and efficiently return a list of differences.
    • Diff Demo
  2. Match:
    • Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
    • Match Demo
  3. Patch:
    • Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.
    • Patch Demo

API Differences

This implementation attempts to be more Nim-like and slightly steps away from the implementations in other languages. List of changes (things may be reverted):

  • Diff is renamed into StringDiff
  • All function names have diff_, match_ and patch_ prefixes removed
  • DiffMatchPatch class is renamed into DMPConfig object
  • Added defaultParams global variable to hold an instance of DMPConfig with it's default values
  • Functions that access algorithm parameters from params: DMPConfig = defaultParams. This way custom parameters could be set explicitly when needed
  • to be continued

Tests

Just run

nimble test