A markdown-focused diff and patch library with jsondiffpatch-compatible interfaces.
npm install markdowndiffpatchimport markdownDiffPatch from 'markdowndiffpatch';
const left = '# Hello\n\nThis is a test.';
const right = '# Hello\n\nThis is a test.\n\nNew paragraph.';
// Create a diff
const delta = markdownDiffPatch.diff(left, right);
// Apply the patch
const patched = markdownDiffPatch.patch(left, delta);
// Reverse the patch
const unpatched = markdownDiffPatch.unpatch(right, delta);
// Reverse the delta
const reversedDelta = markdownDiffPatch.reverse(delta);Creates a diff between two markdown strings. Returns undefined if the strings are identical.
Applies a diff to a markdown string.
Reverses a patch operation.
Reverses a delta so that it can be applied in the opposite direction.
- jsondiffpatch - Diff & patch JavaScript objects
- htmldiffpatch - Diff & patch for HTML documents
MIT