Add DAISY HTML builder.
[librarian.git] / src / librarian / elements / footnotes / __init__.py
1 from ..base import WLElement
2
3
4 class Footnote(WLElement):
5     def txt_build(self, builder):
6         pass
7
8     def html_build(self, builder):
9         if not builder.with_footnotes:
10             return
11
12         builder.footnote_counter += 1
13         fn_no = builder.footnote_counter
14         footnote_id = 'footnote-idm{}'.format(self.attrib['_compat_ordered_id'])
15         anchor_id = 'anchor-idm{}'.format(self.attrib['_compat_ordered_id'])
16
17         builder.start_element('a', {"href": '#{}'.format(footnote_id), "class": "annotation"})
18         builder.push_text('[{}]'.format(fn_no))
19         builder.end_element()
20         
21         builder.enter_fragment('footnotes')
22         builder.start_element('div', {'class': 'fn-{}'.format(self.tag)})
23         builder.push_text('\n') # Compat
24         builder.start_element('a', {'name': footnote_id})
25         builder.end_element()
26         builder.start_element('a', {
27             'href': '#{}'.format(anchor_id), 'class': 'annotation'
28         })
29         builder.push_text('[{}]'.format(fn_no))
30         builder.end_element()
31
32         builder.start_element('p')
33         super(Footnote, self).html_build(builder)
34
35         builder.push_text(' [{}]'.format(self.qualifier))
36         builder.end_element()
37         builder.end_element()
38         builder.exit_fragment()
39
40
41 class PA(Footnote):
42     """Przypis autorski."""
43     @property
44     def qualifier(self):
45         _ = self.gettext
46         return _("author's footnote")
47
48
49 class PT(Footnote):
50     """Przypis tłumacza."""
51     @property
52     def qualifier(self):
53         _ = self.gettext
54         return _("translator's footnote")
55
56
57 class PR(Footnote):
58     """Przypis redakcyjny."""
59     @property
60     def qualifier(self):
61         _ = self.gettext
62         return _("editor's footnote")
63
64
65 class PE(Footnote):
66     """Przypis redakcji źródła."""
67     @property
68     def qualifier(self):
69         _ = self.gettext
70         return _("source editor's footnote")