Solving two bugs in the diff
This commit is contained in:
parent
d3ba49d040
commit
afff1f35f8
@ -736,8 +736,7 @@ angular.module('OpenSlidesApp.motions', [
|
||||
oldText = data.outerContextStart + data.innerContextStart +
|
||||
data.html + data.innerContextEnd + data.outerContextEnd;
|
||||
|
||||
var diff = diffService.diff(oldText, this.text, lineLength, this.line_from);
|
||||
return lineNumberingService.insertLineNumbers(diff, lineLength, highlight, null, this.line_from);
|
||||
return diffService.diff(oldText, this.text, lineLength, this.line_from);
|
||||
},
|
||||
getType: function(original_full_html) {
|
||||
return this.type;
|
||||
|
@ -963,6 +963,17 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
if (this._diffDetectBrokenDiffHtml(diffUnnormalized)) {
|
||||
diff = this._diffParagraphs(htmlOld, htmlNew, lineLength, firstLineNumber);
|
||||
} else {
|
||||
diffUnnormalized = diffUnnormalized.replace(/<ins>.*?(\n.*?)*<\/ins>/gi, function (found) {
|
||||
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<ins>'; });
|
||||
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</ins>' + match; });
|
||||
return found;
|
||||
});
|
||||
diffUnnormalized = diffUnnormalized.replace(/<del>.*?(\n.*?)*<\/del>/gi, function (found) {
|
||||
found = found.replace(/<(div|p|li)[^>]*>/gi, function(match) { return match + '<del>'; });
|
||||
found = found.replace(/<\/(div|p|li)[^>]*>/gi, function(match) { return '</del>' + match; });
|
||||
return found;
|
||||
});
|
||||
|
||||
var node = document.createElement('div');
|
||||
node.innerHTML = diffUnnormalized;
|
||||
diff = node.innerHTML;
|
||||
|
@ -351,5 +351,17 @@ describe('linenumbering', function () {
|
||||
|
||||
expect(diff).toBe("<P class=\"p1 delete\">Test1 Test2</P><P class=\"p2 insert\">Test1 Test2</P>");
|
||||
});
|
||||
|
||||
it('handles inserted paragraphs', function () {
|
||||
var before = "<P>liebliche Stimme, aber deine Stimme ist rauh; du bist der Wolf.' Da gieng der </P>",
|
||||
after = "<p>liebliche Stimme, aber deine Stimme ist rauh; du bist der Wolf.'</p>\
|
||||
\
|
||||
<p>Der Wolf hatte danach richtig schlechte laune, trank eine Flasche Rum,</p>\
|
||||
\
|
||||
<p>machte eine Weltreise und kam danach wieder um die Ziegen zu fressen. Da ging der</p>";
|
||||
var diff = diffService.diff(before, after);
|
||||
|
||||
expect(diff).toBe("<p>liebliche Stimme, aber deine Stimme ist rauh; du bist der <del>Wolf.' </del><ins>Wolf.'</ins></p><p><ins>Der Wolf hatte danach richtig schlechte laune, trank eine Flasche Rum,</ins></p><p><ins>machte eine Weltreise und kam danach wieder um die Ziegen zu fressen. </ins>Da gi<del>e</del>ng der</p>");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user