- self.tags.append(u'br')
- self.handle_curdata() # just handle the data, don't do anything else
- self.tags.pop()
+ self.handle_br()
+ elif tag.lower() == u'img':
+ self.handle_image(attrs)
+ return
+
+ def handle_br(self):
+ self.handle_curdata()
+ self.opentags.append(u'br')
+ self.handle_curdata()
+ self.opentags.pop()
+
+ def handle_image(self, attrs):
+ alt = u''
+ url = u''
+ for attr in attrs:
+ if attr[0] == 'alt':
+ alt = attr[1].decode('utf-8')
+ elif attr[0] == 'src':
+ url = attr[1].decode('utf-8')
+ if url:
+ self.curdata = self.curdata \
+ + u' [img:' \
+ + url
+ if alt:
+ self.curdata = self.curdata \
+ + u'(' \
+ + alt \
+ + u')'
+ self.curdata = self.curdata \
+ + u']'