Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions html2text.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ def google_fixed_width_font(style):
def list_numbering_start(attrs):
"""extract numbering from list element attributes"""
if 'start' in attrs:
return int(attrs['start']) - 1
else:
return 0
try:
return int(attrs['start']) - 1
except ValueError:
pass

return 0

class HTML2Text(HTMLParser.HTMLParser):
def __init__(self, out=None, baseurl=''):
Expand Down
8 changes: 8 additions & 0 deletions test/invalid_start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<body>
<ol start="invalid">
<li>The ol has an invalid start </li>
<li>This should just be ignored </li>
</ol>
</body>
</html>
3 changes: 3 additions & 0 deletions test/invalid_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. The ol has an invalid start
2. This should just be ignored