Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: aaronsw/html2text
base: 0fbc6af7b3
...
head fork: aaronsw/html2text
compare: 8ae9193a02
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 18, 2012
@wking wking test/pre: add test showing poor handling of initial crowded <pre> da88a6d
@wking wking Fix initial crowded <pre> output cc02194
@wking wking Remove extra newline from before list <pre> blocks
My crowded-pre fix broke <pre> blocks in lists:

  $ diff -u preformatted_in_list.md preformatted_in_list-module_output.md
  --- preformatted_in_list.md
  +++ preformatted_in_list-module_output.md
  @@ -1,5 +1,6 @@
     * Run this command:

  +
           ls -l *.html

     * ?

There is a fair amount of trailing whitespace in html2text output, and
I'm not sure where it all comes from.  This patch removes the extra
newline (fixing the test), but it also tweaks the amount of trailing
whitespace in the expected blank line (probably not a problem).
eb09b6d
Commits on Nov 19, 2012
@aaronsw Merge pull request #63 from wking/master
Fix initial crowded <pre> output
8ae9193
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
* ?

No commit comments for this range

Something went wrong with that request. Please try again.