Skip to content

Commit

Permalink
Fix wrapping in the presence of <br>. Fixes #12.
Browse files Browse the repository at this point in the history
  • Loading branch information
eevee committed Sep 12, 2012
1 parent 4d2fc96 commit 8363309
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
10 changes: 6 additions & 4 deletions html2text.py
Expand Up @@ -701,9 +701,11 @@ def optwrap(self, text):
for para in text.split("\n"):
if len(para) > 0:
if not skipwrap(para):
for line in wrap(para, self.body_width):
result += line + "\n"
result += "\n"
result += "\n".join(wrap(para, self.body_width))
if para.endswith(' '):
result += " \n"
else:
result += "\n\n"
newlines = 2
else:
if not onlywhite(para):
Expand Down Expand Up @@ -764,7 +766,7 @@ def main():

p = optparse.OptionParser('%prog [(filename|url) [encoding]]',
version='%prog ' + __version__)
p.add_option("--ignore-emphasis", dest="ignore_emphasis", action="store_true",
p.add_option("--ignore-emphasis", dest="ignore_emphasis", action="store_true",
default=IGNORE_EMPHASIS, help="don't include any formatting for emphasis")
p.add_option("--ignore-links", dest="ignore_links", action="store_true",
default=IGNORE_ANCHORS, help="don't include any formatting for links")
Expand Down
6 changes: 2 additions & 4 deletions test/normal.md
Expand Up @@ -17,8 +17,7 @@ text to separate lists
3. end

**bold**
_italic_

_italic_


def func(x):
Expand All @@ -27,7 +26,6 @@ _italic_
return 'b'


Some `fixed width text` here

Some `fixed width text` here
_`italic fixed width text`_

9 changes: 3 additions & 6 deletions test/url-escaping.md
Expand Up @@ -10,11 +10,8 @@ sound.

And here are images with tricky attribute values:

![\(banana\)](http://placehold.it/350x150#\(banana\))

![\[banana\]](http://placehold.it/350x150#\[banana\])

![{banana}](http://placehold.it/350x150#{banana})

![\(banana\)](http://placehold.it/350x150#\(banana\))
![\[banana\]](http://placehold.it/350x150#\[banana\])
![{banana}](http://placehold.it/350x150#{banana})
![\(\[{}\]\)](http://placehold.it/350x150#\(\[{}\]\))

0 comments on commit 8363309

Please sign in to comment.