Skip to content

FlatFilers/markdowndiffpatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdowndiffpatch

npm version npm downloads License: MIT TypeScript

A markdown-focused diff and patch library with jsondiffpatch-compatible interfaces.

Installation

npm install markdowndiffpatch

Usage

import 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);

API

diff(left: string, right: string, options?: DiffOptions): DiffResult | undefined

Creates a diff between two markdown strings. Returns undefined if the strings are identical.

patch(left: string, delta: DiffResult, options?: PatchOptions): string

Applies a diff to a markdown string.

unpatch(right: string, delta: DiffResult): string

Reverses a patch operation.

reverse(delta: DiffResult): DiffResult

Reverses a delta so that it can be applied in the opposite direction.

Related Projects

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •