Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #63 from wking/master

Fix initial crowded <pre> output
  • Loading branch information...
commit 8ae9193a02866c2b29614f1f30e4007b1655851a 2 parents 0fbc6af + eb09b6d
@aaronsw authored
View
12 html2text.py
@@ -593,17 +593,25 @@ def o(self, data, puredata=0, force=0):
if self.startpre:
#self.out(" :") #TODO: not output when already one there
- self.startpre = 0
+ if not data.startswith("\n"): # <pre>stuff...
+ data = "\n" + data
bq = (">" * self.blockquote)
if not (force and data and data[0] == ">") and self.blockquote: bq += " "
if self.pre:
- bq += " "
+ if not self.list:
+ bq += " "
+ #else: list content is already partially indented
for i in xrange(len(self.list)):
bq += " "
data = data.replace("\n", "\n"+bq)
+ if self.startpre:
+ self.startpre = 0
+ if self.list:
+ data = data.lstrip("\n") # use existing initial indentation
+
if self.start:
self.space = 0
self.p_p = 0
View
13 test/pre.html
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>initial crowsed pre handling test #1</title>
+ </head>
+ <body>
+<pre>a
+b
+c</pre>
+
+ <p>Ensure that HTML that starts with a crowded <code>&lt;pre&gt;</code>
+ is converted to reasonable Markdown.</p>
+ </body>
+</html>
View
8 test/pre.md
@@ -0,0 +1,8 @@
+
+ a
+ b
+ c
+
+Ensure that HTML that starts with a crowded `<pre>` is converted to reasonable
+Markdown.
+
View
2  test/preformatted_in_list.md
@@ -1,5 +1,5 @@
* Run this command:
-
+
ls -l *.html
* ?
Please sign in to comment.
Something went wrong with that request. Please try again.