diff --git a/src/node.js b/src/node.js index 8ca8fca3..675e9799 100644 --- a/src/node.js +++ b/src/node.js @@ -22,13 +22,15 @@ function flankingWhitespace (node) { var trailing = '' if (!node.isBlock) { - var hasLeading = /^[ \r\n\t]/.test(node.textContent) - var hasTrailing = /[ \r\n\t]$/.test(node.textContent) + var hasLeading = /^\s/.test(node.textContent) + var hasTrailing = /\s$/.test(node.textContent) + var blankWithSpaces = node.isBlank && hasLeading && hasTrailing if (hasLeading && !isFlankedByWhitespace('left', node)) { leading = ' ' } - if (hasTrailing && !isFlankedByWhitespace('right', node)) { + + if (!blankWithSpaces && hasTrailing && !isFlankedByWhitespace('right', node)) { trailing = ' ' } } diff --git a/test/index.html b/test/index.html index b52c5928..b4d6215e 100644 --- a/test/index.html +++ b/test/index.html @@ -888,6 +888,20 @@
![](http://example.com/logo.png)+
Foo Bar
+Foo Bar+
Foo Bar
+Foo Bar+