From ccf8b874fa8932f2b038bd0c107b6bcf78a39ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Wed, 20 Nov 2019 09:55:11 +0100 Subject: [PATCH 1/3] Add support for
 tags

---
 markdownify/__init__.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 25608bf..ee01e36 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -62,7 +62,8 @@ def process_tag(self, node, children_only=False):
         # Convert the children first
         for el in node.children:
             if isinstance(el, NavigableString):
-                text += self.process_text(six.text_type(el))
+                # Blank chars shall be striped except in 
+                text += self.process_text(six.text_type(el), keep_whitespaces=(node.name == 'pre'))
             else:
                 text += self.process_tag(el)
 
@@ -73,7 +74,9 @@ def process_tag(self, node, children_only=False):
 
         return text
 
-    def process_text(self, text):
+    def process_text(self, text, keep_whitespaces=False):
+        if keep_whitespaces:
+            return escape(text or '')
         return escape(whitespace_re.sub(' ', text or ''))
 
     def __getattr__(self, attr):
@@ -175,6 +178,9 @@ def convert_li(self, el, text):
     def convert_p(self, el, text):
         return '%s\n\n' % text if text else ''
 
+    def convert_pre(self, el, text):
+        return '```%s\n```\n' % text if text else ''
+
     def convert_strong(self, el, text):
         return '**%s**' % text if text else ''
 

From d7b262f81ae17dcf9385c56988fe8413329dd50c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi?= 
Date: Wed, 20 Nov 2019 10:09:04 +0100
Subject: [PATCH 2/3] Add support for  tags

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

diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index ee01e36..360e06b 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -130,6 +130,9 @@ def convert_blockquote(self, el, text):
     def convert_br(self, el, text):
         return '  \n'
 
+    def convert_code(self, el, text):
+        return '`%s`' % text if text else ''
+
     def convert_em(self, el, text):
         return '*%s*' % text if text else ''
 

From a825ce5c1dcae54d933e103e364d0d0e9f652fde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi?= 
Date: Wed, 20 Nov 2019 10:09:20 +0100
Subject: [PATCH 3/3] Add support for  and  tags

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

diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 360e06b..0a18193 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -133,6 +133,9 @@ def convert_br(self, el, text):
     def convert_code(self, el, text):
         return '`%s`' % text if text else ''
 
+    def convert_del(self, el, text):
+        return '~~%s~~' % text if text else ''
+
     def convert_em(self, el, text):
         return '*%s*' % text if text else ''
 
@@ -184,6 +187,9 @@ def convert_p(self, el, text):
     def convert_pre(self, el, text):
         return '```%s\n```\n' % text if text else ''
 
+    def convert_s(self, el, text):
+        return self.convert_del(el, text)
+
     def convert_strong(self, el, text):
         return '**%s**' % text if text else ''