1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
$NetBSD: patch-aa,v 1.3 2008/02/19 10:31:54 schmonz Exp $
--- html2text.py.orig 2008-02-13 16:24:14.000000000 -0500
+++ html2text.py
@@ -150,7 +150,7 @@ class _html2text(sgmllib.SGMLParser):
self.lastWasNL = 0
def outtextf(self, s):
- if type(s) is type(''): s = codecs.utf_8_decode(s)[0]
+ if type(s) is type(''): s = codecs.utf_8_decode(s, "replace")[0]
self.outtext += s
def close(self):
@@ -262,6 +262,7 @@ class _html2text(sgmllib.SGMLParser):
if attrs.has_key('src'):
attrs['href'] = attrs['src']
alt = attrs.get('alt', '')
+ alt = re.sub('\n', ' ', alt)
i = self.previousIndex(attrs)
if i is not None:
attrs = self.a[i]
@@ -282,7 +283,7 @@ class _html2text(sgmllib.SGMLParser):
if tag in ["ol", "ul"]:
if start:
self.list.append({'name':tag, 'num':0})
- else:
+ elif self.list:
if self.list: self.list.pop()
self.p()
|