diff --git a/openslides/motions/static/js/motions/diff.js b/openslides/motions/static/js/motions/diff.js index 8ad99cf73..1b1ecd64d 100644 --- a/openslides/motions/static/js/motions/diff.js +++ b/openslides/motions/static/js/motions/diff.js @@ -890,6 +890,22 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi return true; } + // 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 :) + var findDel = /(.*?)<\/del>/gi, + findIns = /(.*?)<\/ins>/gi, + found; + while (!!(found = findDel.exec(html))) { + if (found[1].match(/<[^>]*>/)) { + return true; + } + } + while (!!(found = findIns.exec(html))) { + if (found[1].match(/<[^>]*>/)) { + return true; + } + } + // If too much of the text is changed, it's better to separate the old from new new version, // otherwise the result looks strange if (this._calcChangeRatio(html) > 0.66) { @@ -1010,7 +1026,7 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi return out; }); - + var diff; if (this._diffDetectBrokenDiffHtml(diffUnnormalized)) { diff = this._diffParagraphs(htmlOld, htmlNew, lineLength, firstLineNumber); diff --git a/tests/karma/motions/diff.service.test.js b/tests/karma/motions/diff.service.test.js index d338c23f6..404681cd5 100644 --- a/tests/karma/motions/diff.service.test.js +++ b/tests/karma/motions/diff.service.test.js @@ -390,6 +390,19 @@ describe('linenumbering', function () { expect(diff).toBe(expected); }); + it('handles inserted paragraphs (2)', function () { + // Specifically, Noch

should not be enclosed by ..., as Noch

would be seriously broken + var before = "

rief sie alle sieben herbei und sprach 'liebe Kinder, ich will hinaus in den Wald, seid

", + after = "

rief sie alle sieben herbei und sprach 'liebe Kinder, ich will hinaus in den Wald, seid Noch

" + + "

Test 123

", + expected = "

rief sie alle sieben herbei und sprach 'liebe Kinder, ich will hinaus in den Wald, seid

" + + "

rief sie alle sieben herbei und sprach 'liebe Kinder, ich will hinaus in den Wald, seid Noch

" + + "

Test 123

"; + + var diff = diffService.diff(before, after); + expect(diff).toBe(expected); + }); + it('handles completely deleted paragraphs', function () { var before = "

Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.

", after = "";