From 001b1881d00dd0fadc4cf4baf83b18222408163f Mon Sep 17 00:00:00 2001 From: David Chester Date: Tue, 14 May 2019 13:15:15 +0000 Subject: [PATCH 1/2] 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* From f0d37ad3c5c21125a33cb5f83b4696aacf6373ee Mon Sep 17 00:00:00 2001 From: David Chester Date: Tue, 14 May 2019 13:20:05 +0000 Subject: [PATCH 2/2] rename test files to match convention --- ...line-elements.html => #697.space-between-inline-elements.html} | 0 ...n-inline-elements.md => #697.space-between-inline-elements.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/functional/makehtml/cases/issues/{space-between-inline-elements.html => #697.space-between-inline-elements.html} (100%) rename test/functional/makehtml/cases/issues/{space-between-inline-elements.md => #697.space-between-inline-elements.md} (100%) diff --git a/test/functional/makehtml/cases/issues/space-between-inline-elements.html b/test/functional/makehtml/cases/issues/#697.space-between-inline-elements.html similarity index 100% rename from test/functional/makehtml/cases/issues/space-between-inline-elements.html rename to test/functional/makehtml/cases/issues/#697.space-between-inline-elements.html diff --git a/test/functional/makehtml/cases/issues/space-between-inline-elements.md b/test/functional/makehtml/cases/issues/#697.space-between-inline-elements.md similarity index 100% rename from test/functional/makehtml/cases/issues/space-between-inline-elements.md rename to test/functional/makehtml/cases/issues/#697.space-between-inline-elements.md