Merge pull request #3548 from CatoTH/Bugfix-Diff-Inserted-Whitespace-After-BR

Diff-Bugfix: Whitespace was inserted after <br>
This commit is contained in:
Emanuel Schütze 2018-01-22 09:26:28 +01:00 committed by GitHub
commit 172581d557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -38,7 +38,7 @@ Motions:
- Bugfix: Several bugfixes regarding splitting list items in
change recommendations [#3288].
- Bugfix: Several bugfixes regarding diff version [#3407, #3408, #3410,
#3440, #3450, #3465, #3537, #3546].
#3440, #3450, #3465, #3537, #3546, #3548].
- Added inline Editing for motion reason [#3361].
- Added multiselect filter for motion comments [#3372].
- Added support for pinning personal notes to the window [#3360].

View File

@ -675,6 +675,9 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
for (var ent in entities) {
html = html.replace(new RegExp(ent, 'g'), entities[ent]);
}
// Newline characters: after closing block-level-elements, but not after BR (which is inline)
html = html.replace(/(<br *\/?>)\n/gi, "$1");
html = html.replace(/[ \n\t]+/gi, ' ');
html = html.replace(/(<\/(div|p|ul|li|blockquote>)>) /gi, "$1\n");

View File

@ -423,6 +423,14 @@ describe('linenumbering', function () {
expect(diff).toBe('The <strong>brown</strong> spotted fox <del>jum</del><ins>lea</ins>ped over the rolling log.');
});
it('does not insert spaces after a unchanged BR tag', function() {
var before = "<p>" + noMarkup(1) + "Hendl Kirwa hod Maßkruag<br>" + noMarkup(2) + "gmahde Wiesn</p>",
after = "<p>Hendl Kirwa hod Maßkruag<br>\ngmahde Wiesn</p>";
var diff = diffService.diff(before, after);
expect(diff).toBe(before);
});
it('does not mark the last line of a paragraph as change if a long new one is appended', function () {
var before = "<p><span class=\"os-line-number line-number-5\" data-line-number=\"5\" contenteditable=\"false\">&nbsp;</span>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>",
after = "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>\n" +
@ -534,7 +542,7 @@ describe('linenumbering', function () {
after = "<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>";
var diff = diffService.diff(before, after);
expect(diff).toBe('<p>sem. Nulla consequat massa quis enim.<ins> TEST<br> TEST</ins></p>');
expect(diff).toBe('<p>sem. Nulla consequat massa quis enim.<ins> TEST<br>TEST</ins></p>');
});
it('does not repeat the last word (2)', function () {