1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """
22 Transformation of the formatted record into an HTML representation.
23 """
24
25 from xml.sax.saxutils import escape
26 from StringIO import StringIO
27
28 from Pyblio.Format.Generator import Generator as Base
29
31
32
33 return ' '.join(['%s="%s"' % (k.lstrip('_'), v)
34 for k, v in attrs.items()])
35
36
38
40 self.fd = fd
41 return
42
45
47 self.fd.write('<i>')
48 for s in t.children: self(s)
49 self.fd.write('</i>')
50
52 self.fd.write('<small>')
53 for s in t.children: self(s)
54 self.fd.write('</small>')
55
57 attrs = _mkattrs(t.attributes)
58 self.fd.write('<span %s>' % attrs)
59 for s in t.children: self(s)
60 self.fd.write('</span>')
61
63 self.fd.write('<b>')
64 for s in t.children: self(s)
65 self.fd.write('</b>')
66
68 attrs = _mkattrs(t.attributes)
69 self.fd.write('<a %s>' % attrs)
70 for s in t.children: self(s)
71 self.fd.write('</a>')
72
75
77 self.fd.write('<table>\n')
78
80 self.fd.write('</table>')
81
83 self.fd.write('<tr><td>[%s]</td><td>' % escape(key))
84
86 self.fd.write('</td></tr>\n')
87
88
90 """ Convenience function that generates the HTML in a string """
91 fd = StringIO()
92 g = Generator(fd)
93 g(t)
94
95 return fd.getvalue()
96