How to use the diff2html.Diff2Html.getPrettyHtmlFromJson 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 FredrikNoren / ungit / components / textdiff / textdiff.js View on Github external
blocks.push(block);
          }
          lineCount += length;
          return blocks;
        }, []);
      }
      this.diffJson[0].isTrimmed = true;

      this.loadMoreCount(Math.min(loadLimit, Math.max(0, lineCount - this.loadCount)));

      let html;

      if (this.textDiffType.value() === 'sidebysidediff') {
        html = diff2html.getPrettySideBySideHtmlFromJson(this.diffJson);
      } else {
        html = diff2html.getPrettyHtmlFromJson(this.diffJson);
      }

      this.numberOfSelectedPatchLines = 0;
      let index = 0;

      // ko's binding resolution is not recursive, which means below ko.bind refresh method doesn't work for
      // data bind at getPatchCheckBox that is rendered with "html" binding.
      // which is reason why manually updating the html content and refreshing kobinding to have it render...
      if (this.patchLineList) {
        html = html.replace(/<span class="d2h-code-line-[a-z]+">(\+|\-)/g, (match, capture) =&gt; {
          if (this.patchLineList()[index] === undefined) {
            this.patchLineList()[index] = true;
          }

          return this.getPatchCheckBox(capture, index, this.patchLineList()[index++]);
        });</span>
github pbu88 / diffy / frontend / src / app / diff-detail-content / diff-detail-content.component.ts View on Github external
renderDiff(): string {
        if(this.fileToRender) {
            return Diff2Html.getPrettyHtmlFromJson(
                this.sharedDiff.diff.filter(
                    fileContent => printerUtils.getHtmlId(fileContent) == this.fileToRender));
        }
        return Diff2Html.getPrettyHtmlFromJson(
            [this.sharedDiff.diff[0]]);
    }
github pbu88 / diffy / frontend / src / app / diff-detail-content / diff-detail-content.component.ts View on Github external
renderDiff(): string {
        if(this.fileToRender) {
            return Diff2Html.getPrettyHtmlFromJson(
                this.sharedDiff.diff.filter(
                    fileContent => printerUtils.getHtmlId(fileContent) == this.fileToRender));
        }
        return Diff2Html.getPrettyHtmlFromJson(
            [this.sharedDiff.diff[0]]);
    }