Merge pull request #4361 from CatoTH/OS3-Diff-Bugfix-With-Newlines
Diff-Bugfix: Newlines and split paragraphs
This commit is contained in:
commit
1920eb18c7
@ -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 =
|
||||||
|
'<P>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.</P>',
|
||||||
|
after =
|
||||||
|
'<p>Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.</p>\n<p>Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.';
|
||||||
|
const diff = service.diff(before, after);
|
||||||
|
|
||||||
|
expect(diff).toBe(
|
||||||
|
'<P class="delete">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.</P>' +
|
||||||
|
'<P class="insert">Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.</P>' +
|
||||||
|
'<INS>\n</INS>' +
|
||||||
|
'<P class="insert">Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.</P>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
it('does not repeat the last word (1)', inject([DiffService], (service: DiffService) => {
|
it('does not repeat the last word (1)', inject([DiffService], (service: DiffService) => {
|
||||||
const before = '<P>sem. Nulla consequat massa quis enim. </P>',
|
const before = '<P>sem. Nulla consequat massa quis enim. </P>',
|
||||||
after = '<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>';
|
after = '<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>';
|
||||||
|
@ -939,8 +939,8 @@ export class DiffService {
|
|||||||
private diffDetectBrokenDiffHtml(html: string): boolean {
|
private diffDetectBrokenDiffHtml(html: string): boolean {
|
||||||
// If other HTML tags are contained within INS/DEL (e.g. "<ins>Test</p></ins>"), let's better be cautious
|
// If other HTML tags are contained within INS/DEL (e.g. "<ins>Test</p></ins>"), let's better be cautious
|
||||||
// The "!!(found=...)"-construction is only used to make jshint happy :)
|
// The "!!(found=...)"-construction is only used to make jshint happy :)
|
||||||
const findDel = /<del>(.*?)<\/del>/gi,
|
const findDel = /<del>([\s\S]*?)<\/del>/gi,
|
||||||
findIns = /<ins>(.*?)<\/ins>/gi;
|
findIns = /<ins>([\s\S]*?)<\/ins>/gi;
|
||||||
let found, inner;
|
let found, inner;
|
||||||
while (!!(found = findDel.exec(html))) {
|
while (!!(found = findDel.exec(html))) {
|
||||||
inner = found[1].replace(/<br[^>]*>/gi, '');
|
inner = found[1].replace(/<br[^>]*>/gi, '');
|
||||||
|
Loading…
Reference in New Issue
Block a user