2 from __future__ import unicode_literals
4 from ..base import WLElement
7 class Footnote(WLElement):
8 def txt_build(self, builder):
11 def html_build(self, builder):
12 if not builder.with_footnotes:
15 builder.footnote_counter += 1
16 fn_no = builder.footnote_counter
17 footnote_id = 'footnote-idm{}'.format(self.attrib['_compat_ordered_id'])
18 anchor_id = 'anchor-idm{}'.format(self.attrib['_compat_ordered_id'])
21 builder.start_element(
24 "href": '#{}'.format(footnote_id),
25 "class": "annotation-anchor",
29 builder.push_text('[{}]'.format(fn_no))
32 # Add actual footnote.
33 builder.enter_fragment('footnotes')
34 builder.start_element('div', {'class': 'fn-{}'.format(self.tag)})
35 builder.push_text('\n') # Compat
36 builder.start_element('a', {'name': footnote_id})
38 builder.start_element('a', {
39 'href': '#{}'.format(anchor_id), 'class': 'annotation'
41 builder.push_text('[{}]'.format(fn_no))
44 builder.start_element('p')
45 super(Footnote, self).html_build(builder)
47 builder.push_text(' [{}]'.format(self.qualifier))
50 builder.exit_fragment()
52 def epub_build(self, builder):
53 fn_no = builder.assign_footnote_number()
54 part_number = getattr(
60 builder.start_element(
64 'id': f'anchor-{fn_no}',
65 'href': f'annotations.xhtml#annotation-{fn_no}',
68 builder.start_element('sup', {})
69 builder.push_text(str(fn_no))
74 builder.enter_fragment('footnotes')
75 builder.start_element('p', {
76 'id': f'annotation-{fn_no}',
79 builder.start_element('a', {
80 'href': f"part{part_number}.xhtml#anchor-{fn_no}"
82 builder.push_text(str(fn_no))
84 builder.push_text('. ')
86 super().epub_build(builder)
87 builder.push_text(' [' + self.qualifier + ']')
90 builder.push_text('\n')
92 builder.exit_fragment()
97 """Przypis autorski."""
101 return _("author's footnote")
105 """Przypis tłumacza."""
109 return _("translator's footnote")
113 """Przypis redakcyjny."""
117 return _("editor's footnote")
121 """Przypis redakcji źródła."""
125 return _("source editor's footnote")