diff --git a/src/utils/DOMUtils.js b/src/utils/DOMUtils.js index c790b06..b659b55 100644 --- a/src/utils/DOMUtils.js +++ b/src/utils/DOMUtils.js @@ -103,10 +103,12 @@ export default class DOMUtils { (tag.textContent === '' || tag.textContent === ' ' || tag.textContent === ' ' - || tag.textContent.charCodeAt(0) === 160) + || (tag.textContent.charCodeAt(0) === 160 && tag.textContent.length === 1)) && !tag.querySelector(DOMUtils.EMPTY_TAGS_TO_PRESERVE.join(',')) ) { tag.remove(); + } else { + tag.innerHTML = tag.innerHTML.replace(/ /gm, ' '); } } } diff --git a/test/importers/fixtures/space.spec.html b/test/importers/fixtures/space.spec.html index f1415d8..de75e29 100644 --- a/test/importers/fixtures/space.spec.html +++ b/test/importers/fixtures/space.spec.html @@ -4,10 +4,11 @@
A simple paragraph
A paragraph with a br inside.
This should be next line.
A paragraph with a br at the end.
A paragraph with a br at the end and " ".
A paragraph followed by a br
A paragraph after the br
- +
A paragraph after the nbsp;