diff --git a/client/src/app/core/ui-services/diff.service.spec.ts b/client/src/app/core/ui-services/diff.service.spec.ts index 4fdcc2db5..38c373aee 100644 --- a/client/src/app/core/ui-services/diff.service.spec.ts +++ b/client/src/app/core/ui-services/diff.service.spec.ts @@ -809,6 +809,24 @@ describe('DiffService', () => { ); })); + it('does not like splitting paragraphs too much, but respects line breaks between paragraphs', inject( + [DiffService], + (service: DiffService) => { + const before = + '

Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher. Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.

', + after = + '

Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.

\n

Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.'; + const diff = service.diff(before, after); + + expect(diff).toBe( + '

Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher. Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.

' + + '

Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.

' + + '\n' + + '

Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.

' + ); + } + )); + it('does not repeat the last word (1)', inject([DiffService], (service: DiffService) => { const before = '

sem. Nulla consequat massa quis enim. 

', after = '

sem. Nulla consequat massa quis enim. TEST
\nTEST

'; diff --git a/client/src/app/core/ui-services/diff.service.ts b/client/src/app/core/ui-services/diff.service.ts index c140a7cf3..ec77aa38c 100644 --- a/client/src/app/core/ui-services/diff.service.ts +++ b/client/src/app/core/ui-services/diff.service.ts @@ -939,8 +939,8 @@ export class DiffService { private diffDetectBrokenDiffHtml(html: string): boolean { // If other HTML tags are contained within INS/DEL (e.g. "Test

"), let's better be cautious // The "!!(found=...)"-construction is only used to make jshint happy :) - const findDel = /(.*?)<\/del>/gi, - findIns = /(.*?)<\/ins>/gi; + const findDel = /([\s\S]*?)<\/del>/gi, + findIns = /([\s\S]*?)<\/ins>/gi; let found, inner; while (!!(found = findDel.exec(html))) { inner = found[1].replace(/]*>/gi, '');