From 146104b41fb68a6b6710cf78017d34e5aae3c5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Wed, 20 Nov 2019 10:37:39 +0100 Subject: [PATCH] Remove newline-only textnodes outside

---
 markdownify/__init__.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 25608bf..f97bcbf 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -59,6 +59,11 @@ class MarkdownConverter(object):
     def process_tag(self, node, children_only=False):
         text = ''
 
+        # Clean newline-only textnodes outside 
+        for el in node.children:
+            if node.name != 'pre' and isinstance(el, NavigableString) and six.text_type(el) == '\n':
+                el.extract()
+
         # Convert the children first
         for el in node.children:
             if isinstance(el, NavigableString):