From 001b1881d00dd0fadc4cf4baf83b18222408163f Mon Sep 17 00:00:00 2001 From: David Chester Date: Tue, 14 May 2019 13:15:15 +0000 Subject: [PATCH] preserve spaces between inline elements --- src/converter.js | 2 +- .../makehtml/cases/issues/space-between-inline-elements.html | 1 + .../makehtml/cases/issues/space-between-inline-elements.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 test/functional/makehtml/cases/issues/space-between-inline-elements.html create mode 100644 test/functional/makehtml/cases/issues/space-between-inline-elements.md diff --git a/src/converter.js b/src/converter.js index 58e4e77..e08e51b 100644 --- a/src/converter.js +++ b/src/converter.js @@ -393,7 +393,7 @@ showdown.Converter = function (converterOptions) { for (var n = 0; n < node.childNodes.length; ++n) { var child = node.childNodes[n]; if (child.nodeType === 3) { - if (!/\S/.test(child.nodeValue)) { + if (!/\S/.test(child.nodeValue) && !/^[ ]+$/.test(child.nodeValue)) { node.removeChild(child); --n; } else { diff --git a/test/functional/makehtml/cases/issues/space-between-inline-elements.html b/test/functional/makehtml/cases/issues/space-between-inline-elements.html new file mode 100644 index 0000000..f2e6833 --- /dev/null +++ b/test/functional/makehtml/cases/issues/space-between-inline-elements.html @@ -0,0 +1 @@ +

one two three

diff --git a/test/functional/makehtml/cases/issues/space-between-inline-elements.md b/test/functional/makehtml/cases/issues/space-between-inline-elements.md new file mode 100644 index 0000000..878c4dc --- /dev/null +++ b/test/functional/makehtml/cases/issues/space-between-inline-elements.md @@ -0,0 +1 @@ +*one* *two* *three*