This is the WIP Nim implementation of Neil Fraser's Diff Match and Patch for Google Docs.
The Diff Match and Patch libraries offer robust algorithms to perform the operations required for synchronizing plain text.
- Diff:
- Compare two blocks of plain text and efficiently return a list of differences.
- Diff Demo
- Match:
- Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
- Match Demo
- 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
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 intoStringDiff
- All function names have
diff_
,match_
andpatch_
prefixes removed DiffMatchPatch
class is renamed intoDMPConfig
object- Added
defaultParams
global variable to hold an instance ofDMPConfig
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
Just run
nimble test