infodev
infodev

Reputation: 5235

Show compared strings in Diff2HtmlUI when there is no difference

I'm comparing two json objects then rendering them with Diff2Html

First I'm gnerating a diff string using Diff libbary

const diffString = diff.createTwoFilesPatch('file', 'file', this.reference, this.result, undefined, undefined, {
  context: Number.MAX_SAFE_INTEGER,
});

When the two compared string are equivalent I'm getting an empty string , exactly :

"Index: file\n===================================================================\n--- file\n+++ file\n"

I render the string:

const div: HTMLElement = this.diffDiv.nativeElement;
const diff2htmlUi = new Diff2HtmlUI(div, diffString, this.configuration);
diff2htmlUi.draw();

Then Diff2Html renders this screen:

enter image description here

I would like that the same all of the string object get rendered. I don't find a way to do it

Upvotes: 1

Views: 180

Answers (1)

apestogetherstrong
apestogetherstrong

Reputation: 31

I had the same problem and found out that there is no way to do this (see github issue)

so instead I used their custom templates functionality and changed the template that shows file without changes component to have the whole string in it

Upvotes: 0

Related Questions