How to embed `diff2html` into a node.js application

478 Views Asked by At

I am new to node.js and would like to come up with an application using the diff2html package. Could anybody tell me how a minimalistic implementation could look like (perhaps by completing the code below)?

var http = require('http');
var diff2html = require("diff2html").Diff2Html

http.createServer(function (req, res) {
    // more code here
}).listen(123456);
1

There are 1 best solutions below

0
On

There are only two methods, both are described in the documentation.

The lib is for converting a existing diff to html. So there are the two methods getPrettyHtml() and getJsonFromDiff().

I'm not sure what you want to do, but it would be something like:

var http = require('http');
var diff2html = require("diff2html").Diff2Html

http.createServer(function (req, res) {
    diff2html.getPrettyHtml(YOUR_DIFF_FROM_SOMEWHERE, YOUR_OPTIONS);
}).listen(123456);