Skip to content

inkling/htmldiff.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

htmldiff.js

HTML Diffing in JavaScript

Build Status

htmldiff.js is a JavaScript port of https://github.com/myobie/htmldiff by Keanu Lee at Inkling.

This is diffing that understands HTML. Best suited for cases when you want to show a diff of user-generated HTML (like from a wysiwyg editor).

Usage (JavaScript)

You use it like this:

  diff = require('htmldiff.js');
  console.log(diff('<p>this is some text</p>', '<p>this is some more text</p>'));

And you get:

<p>this is some <ins>more </ins>text</p>

Usage (TypeScript)

  import diff = require("htmldiff");
  console.log(diff("<p>this is some text</p>", "<p>this is some more text</p>"));

diff is just an arbitry name for the exported default module function, you can use any other name you like, e. g.:

  import diffHTML = require("htmldiff");
  console.log(diffHTML("<p>this is some text</p>", "<p>this is some more text</p>"));

Module

It should be multi-module aware. ie. it should work as a node.js module or an AMD (RequireJS) module, or even just as a script tag.

Licensed under the MIT License. See the LICENSE file for details.

About

Diff algorithm that understands HTML, in the browser.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages