From 3bbfc64c40ed41f2bac743ecf795e51aab1e8202 Mon Sep 17 00:00:00 2001
From: Kyle Grinstead
between paragraphs
---
dist/html-diff.js | 6 +-----
src/html-diff.ts | 11 +----------
src/index.test.ts | 13 ++++++++++++-
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/dist/html-diff.js b/dist/html-diff.js
index e806a2f..ecb3af8 100644
--- a/dist/html-diff.js
+++ b/dist/html-diff.js
@@ -381,11 +381,7 @@ class HtmlDiff {
const s = this.newWords[pos];
if (this.config.isIsolatedDiffTagPlaceholder(s) && this.newIsolatedDiffTags[pos]) {
result.push(this.diffIsolatedPlaceholder(operation2, pos, s));
- } else if (s === "\xB6") {
- if (pos > operation2.startInNew && this.newWords[pos - 1] === "
")) {
- result.push("
");
- }
- } else {
+ } else if (s !== "\xB6") {
result.push(s);
}
}
diff --git a/src/html-diff.ts b/src/html-diff.ts
index 464e51f..7af7c4c 100644
--- a/src/html-diff.ts
+++ b/src/html-diff.ts
@@ -385,16 +385,7 @@ export default class HtmlDiff {
const s = this.newWords[pos];
if (this.config.isIsolatedDiffTagPlaceholder(s) && this.newIsolatedDiffTags[pos]) {
result.push(this.diffIsolatedPlaceholder(operation, pos, s));
- } else if (s === '¶') {
- if (
- pos > operation.startInNew &&
- this.newWords[pos - 1] === '
')
- ) {
- result.push('
');
- }
- } else {
+ } else if (s !== '¶') {
result.push(s);
}
}
diff --git a/src/index.test.ts b/src/index.test.ts
index 96bfd05..a1d03cf 100644
--- a/src/index.test.ts
+++ b/src/index.test.ts
@@ -12,6 +12,17 @@ test('works for basic example', () => {
);
});
+test('does not add weird newlines', () => {
+ const result = HtmlDiff.create(
+ `
1. Ancient people who lived in villages near Gaza before they were largely destroyed by a Philistine invasion (Dt 2:23; Jos 13:3).
2. Designation for the inhabitants of the Syrian district of Avva who were relocated by Shalmaneser of Assyria in Samaria after its conquest in 722 BC (2 Kgs 17:31). See Avva.
`, + `1. Ancient people who lived in villages near Gaza before they were largely destroyed by a Philistine invasion (Dt 2:23; Jos 13:3).
2. Designation for the inhabitants of the Syrian district of Avva who were relocated by Shalmaneser of Assyria in Samaria after its conquest in 722 BC (2 Kgs 17:31). See Avva.
` + ).build(); + + expect(result).toBe( + `1. Ancient people who lived in villages near Gaza before they were largely destroyed by a Philistine invasion (Dt 2:23; Jos 13:3).
2. Designation for the inhabitants of the Syrian district of Avva who were relocated by Shalmaneser of Assyria in Samaria after its conquest in 722 BC (2 Kgs 17:31). See Avva.
` + ); +}); + test('works for link', () => { const result = HtmlDiff.create( `Testing Link Changes And when the link stays the same`, @@ -54,6 +65,6 @@ test('works when deleting a paragraph', () => { ).build(); expect(result).toBe( - `one two three four five six..
seven eight nine ten
eleven twelve thirteen.
fourteen fifteen sixteen.
` + `one two three four five six..
seven eight nine ten
eleven twelve thirteen.
fourteen fifteen sixteen.
` ); });