How to use the diff2html.Diff2Html function in diff2html

To help you get started, weโ€™ve selected a few diff2html examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbu88 / diffy / backend / src / Diff.js View on Github external
var Diff2Html = require('diff2html').Diff2Html;
var _ = require('lodash');

(function(){
    /**
     * @param string rawDiffString -- the raw diff string
     */
    function Diff(rawDiffString) {

        /* Fields initialization */
        var jsonDiff = Diff2Html.getJsonFromDiff(rawDiffString);
        var diffFiles = _.map(jsonDiff, (jsonDiffFile) => {
            return new DiffFile(jsonDiffFile);
        });
        
        this.diffFiles = diffFiles;
        this.rawDiff = rawDiffString;
github buzzfeed-openlab / edgar-monitor / edgar-monitor.js View on Github external
var request = require('request'),
    fs = require('fs'),
    exec = require('child_process').exec,
    Diff2Html = require('diff2html').Diff2Html,
    pg = require('pg'),
    cheerio = require('cheerio'),
    uuid = require('node-uuid'),
    aws = require('aws-sdk'),
    s3 = new aws.S3({ apiVersion: '2006-03-01', 'region': 'us-east-1' }),
    ses = new aws.SES({ apiVersion: '2010-12-01', 'region': 'us-east-1' });

function handleError(err) {
    if (err) {
        var timeStamp = (new Date()).toString();
        console.log(timeStamp, ' Error:');
        console.log(err);
        console.log('-------');

        process.exit(1);
    }
github FredrikNoren / ungit / components / sidebysidediff / sidebysidediff.js View on Github external
var ko = require('knockout');
var components = require('ungit-components');
var diff2html = require('diff2html').Diff2Html;

components.register('sidebysidediff', function(args) {
  return new SideBySideDiffViewModel(args);
});

var SideBySideDiffViewModel = function(args) {
  this.filename = args.filename;
  this.repoPath = args.repoPath;
  this.server = args.server;
  this.sha1 = args.sha1;
  this.isMoreToLoad = ko.observable(false);
  this.diffJson = null;
  this.diffHtml = ko.observable();
  this.loadLimit = 100;
}
github FredrikNoren / ungit / components / textdiff / textdiff.js View on Github external
const ko = require('knockout');
const components = require('ungit-components');
const diff2html = require('diff2html').Diff2Html;
const programEvents = require('ungit-program-events');
const promise = require("bluebird");
const sideBySideDiff = 'sidebysidediff';
const textDiff = 'textdiff';

components.register('textdiff', args => new TextDiffViewModel(args));
components.register('textdiff.type', () => new Type());
components.register('textdiff.wordwrap', () => new WordWrap());
components.register('textdiff.whitespace', () => new WhiteSpace());

const loadLimit = 100;

class WordWrap {
  constructor() {
    this.text = ko.observable("No Wrap");
    this.value = ko.observable(false);
github afreeorange / bock / bock-ui / src / Bock.js View on Github external
onupdate: () => {
    document.getElementById('line-compare').innerHTML = Diff2Html.Diff2Html.getPrettyHtml(Articles.comparisonDiff);
    document.getElementById('side-compare').innerHTML = Diff2Html.Diff2Html.getPrettyHtml(Articles.comparisonDiff, { outputFormat: 'side-by-side' });
  },
github tessereact / tessereact / lib / components / _lib / diff / index.js View on Github external
function diffToHTML(diff) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  if (!diff) {
    return '';
  }

  return _diff2html.Diff2Html.getPrettyHtml(diff, {
    outputFormat: options.sideBySide ? 'side-by-side' : 'line-by-line'
  });
}
github krasimir / igit / src / components / Timeline.js View on Github external
function formatReviewDiff(review) {
  const formatter = diff2html.Diff2Html;
  const html = formatter.getPrettyHtml(
    [
      `diff --git ${ review.path } ${ review.path }`,
      `${ review.path }\n${ review.diff_hunk }`
    ].join('\n'),
    {
      inputFormat: 'diff',
      showFiles: false,
      matching: 'none',
      outputFormat: 'line-by-line'
    }
  );

  return html;
}
github afreeorange / bock / bock-ui / src / Bock.js View on Github external
onupdate: () => {
    document.getElementById('line-compare').innerHTML = Diff2Html.Diff2Html.getPrettyHtml(Articles.comparisonDiff);
    document.getElementById('side-compare').innerHTML = Diff2Html.Diff2Html.getPrettyHtml(Articles.comparisonDiff, { outputFormat: 'side-by-side' });
  },
github ataraxie / codeshovel / frontend / src / js / index.js View on Github external
const $ = jQuery = require("jquery");
global.$ = global.jQuery = $;

const Diff2Html = require("diff2html").Diff2Html;
require("../../node_modules/diff2html/dist/diff2html-ui");

let SHOVEL = JSON.parse(EXAMPLE_JSON);
global.SHOVEL = SHOVEL;

let Handlebars = require('handlebars/runtime');

const shovelTemplates = {
	commitTable: require('../templates/commit-table.hbs')
};

let templates = {};
templates["side-by-side-file-diff"] = `
    <div data-lang="{{file.language}}" class="d2h-file-wrapper" id="{{fileHtmlId}}">
        <div class="d2h-file-header">
          {{{filePath}}}</div></div>
github pbu88 / diffy / src / app.js View on Github external
.then((shared_diff) => {
            var jsonDiff = shared_diff.diff;
            jsonDiff = jsonDiff.sort(utils.sortByFilenameCriteria);
            var tree = new FileTree();
            jsonDiff.forEach(function(e) {
                tree.insert(utils.getFileName(e));
            });
            var html = tree.printTree(tree, 0);

            res.render('diff.html', {
                id: id,
                diff: diff2html.Diff2Html.getPrettyHtmlFromJson(jsonDiff),
                fileTreeHtml: html,
                files: jsonDiff,
                dbObj: shared_diff
            });
        },
        (err) => {