jsdifflib
A javascript library for diffing text and generating corresponding HTML views
Last updated 12 years ago by forbeslindesay .
BSD · Repository · Bugs · Original npm
$ cnpm install jsdifflib 
SYNC missed versions from official npm registry.

jsdifflib

A javascript library for diffing text and generating corresponding HTML views. This is a fork of cemerick/jsdifflib which has been updated for use with browserify and node.js

NPM version

Installation

npm install jsdifflib

Overview

jsdifflib is a Javascript library that provides:

  1. a partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class)
  2. a visual diff view generator, that offers side-by-side as well as inline formatting of file data

It puts data in a simple table that can be easilly re-styled using CSS

jsdifflib does not require jQuery or any other Javascript library.

Example

var difflib = require('jsdifflib');

function getDiff(baseTextRaw, newTextRaw) {
  // build the diff view and return a DOM node
  return diffview.buildView({
      baseText: baseText,
      newText: newText,
      // set the display titles for each resource
      baseTextName: "Base Text",
      newTextName: "New Text",
      contextSize: 10,
      //set inine to true if you want inline
      //rather than side by side diff
      inline: true
  });
}

document.body.appendChild(getDiff('source', 'destination'));

License

BSD

Current Tags

  • 1.1.0                                ...           latest (12 years ago)

1 Versions

  • 1.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org