1
#Canto - ncurses RSS reader
2
# Copyright (C) 2008 Jack Miller <jack@codezen.org>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License version 2 as
6
# published by the Free Software Foundation.
12
def get_attr(self, attrs, attr):
13
l = [v for k,v in attrs if k == attr]
17
class LinkHandler(Handler):
24
def match(self, tag, attrs, open, ll):
27
href = self.get_attr(attrs, "href")
35
ll.append((self.content, self.link, self.handler))
37
return u"[" + unicode(len(ll)) + u"]%0"
39
class ImageHandler(Handler):
42
self.handler = "image"
44
def match(self, tag, attrs, open, ll):
47
src = self.get_attr(attrs, "src")
48
alt = self.get_attr(attrs, "alt")
52
extension = src.rsplit('.',1)[-1]
53
ll.append((alt, src, self.handler))
55
return u"%7["+ alt + u"][" + unicode(len(ll)) + u"]%0"