Skip to content

Commit

Permalink
Support Unicode HTML escapes and solve Python3 incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
bordaigorl committed Oct 14, 2014
1 parent 5970d8c commit bfdf029
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/html2text.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def has_key(x, y):
xrange = range

# Use Unicode characters instead of their ascii psuedo-replacements
UNICODE_SNOB = 0
UNICODE_SNOB = 1

# Escape all special characters. Output is less readable, but avoids corner case formatting issues.
ESCAPE_SNOB = 0
Expand Down Expand Up @@ -281,7 +281,7 @@ def close(self):

self.outtext = self.outtext.join(self.outtextlist)
if self.unicode_snob:
nbsp = unichr(name2cp('nbsp'))
nbsp = chr(name2cp('nbsp'))
else:
nbsp = u' '
self.outtext = self.outtext.replace(u'&nbsp_place_holder;', nbsp)
Expand Down Expand Up @@ -801,7 +801,7 @@ def charref(self, name):
return unifiable_n[c]
else:
try:
return unichr(c)
return chr(c)
except NameError: #Python3
return chr(c)

Expand All @@ -813,7 +813,7 @@ def entityref(self, c):
except KeyError: return "&" + c + ';'
else:
try:
return unichr(name2cp(c))
return chr(name2cp(c))
except NameError: #Python3
return chr(name2cp(c))

Expand Down

0 comments on commit bfdf029

Please sign in to comment.