Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions html2text.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ def optwrap(self, text):
assert wrap, "Requires Python 2.3."
result = ''
newlines = 0
reList = re.compile('(^[ ]+[0-9]+\. )|(^[ ]+[%s] )' %(self.ul_item_mark))
for para in text.split("\n"):
if len(para) > 0:
if not skipwrap(para):
Expand All @@ -740,6 +741,17 @@ def optwrap(self, text):
else:
result += "\n\n"
newlines = 2
# Handle list item
elif reList.match(para):
list_prefix = reList.search(para).group()
indent_width = len(list_prefix)
indent_spaces = ' ' * indent_width
list_width = BODY_WIDTH - indent_width
wrapped = wrap(para, list_width)
result += wrapped[0] + "\n"
for line in wrapped[1:]:
result += indent_spaces + line + "\n"
newlines = 1
else:
if not onlywhite(para):
result += para + "\n"
Expand Down