diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 25608bf..0a18193 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):
@@ -127,6 +130,12 @@ 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_del(self, el, text):
+        return '~~%s~~' % text if text else ''
+
     def convert_em(self, el, text):
         return '*%s*' % text if text else ''
 
@@ -175,6 +184,12 @@ 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_s(self, el, text):
+        return self.convert_del(el, text)
+
     def convert_strong(self, el, text):
         return '**%s**' % text if text else ''