node-jsdifflib
A diff library to compare text differences between two texts.
This is a fork of cemerick/jsdifflib which has been adapted to render the HTML on the server.
Installation
npm install node-jsdifflib
Overview
jsdifflib is a Javascript library that provides:
- A partial reimplementation of Python’s difflib module (specifically, the SequenceMatcher class)
- A visual diff view generator, that offers side-by-side as well as inline formatting of file data
API
options
- baseTextName: [string] the title to be displayed above the base text listing in the diff view [default="Base Text"]
- newTextName: [string] the title to be displayed above the new text listing in the diff view [default="New Text"]
- contextSize: [int] the number of lines of context to show around differences; by default, all lines are shown
- inline: [boolean] if false, a side-by-side diff view is generated (default); if true, an inline diff view is generated
- colgroup: [object/boolean] whether to add colgroup tag to table [default = false]
- th: [int] The width (%) of th elements (lines) [default=5]
- td: [int] The width (%) of td elements (content) [default=45]
Style
jsdifflib comes with a ready to use CSS file (assets/jsdifflib.css) or you can use a custom one.
Example
const http = ;const diff = ; const baseFile = "console.log(5);"const newFile = "\"use strict\";\nconsole.log(5);"; http;
License
BSD