2 from __future__ import unicode_literals
4 from ..base import WLElement
7 class Footnote(WLElement):
11 def signal(self, signal):
12 if signal == 'INLINE':
13 self.START_INLINE = False
15 super().signal(signal)
17 def txt_build(self, builder):
20 def html_build(self, builder):
21 if not builder.with_footnotes:
24 builder.footnote_counter += 1
25 fn_no = builder.footnote_counter
26 footnote_id = 'footnote-idm{}'.format(self.attrib['_compat_ordered_id'])
27 anchor_id = 'anchor-idm{}'.format(self.attrib['_compat_ordered_id'])
30 builder.start_element(
33 "href": '#{}'.format(footnote_id),
34 "class": "annotation-anchor",
38 builder.push_text('[{}]'.format(fn_no))
41 # Add actual footnote.
42 builder.enter_fragment('footnotes')
43 builder.start_element('div', {'class': 'fn-{}'.format(self.tag)})
44 builder.push_text('\n') # Compat
45 builder.start_element('a', {'name': footnote_id})
47 builder.start_element('a', {
48 'href': '#{}'.format(anchor_id), 'class': 'annotation'
50 builder.push_text('[{}]'.format(fn_no))
53 builder.start_element('p')
54 super(Footnote, self).html_build(builder)
56 builder.push_text(' [{}]'.format(self.qualifier))
59 builder.exit_fragment()
61 def epub_build(self, builder):
62 fn_no = builder.assign_footnote_number()
63 part_number = getattr(
69 builder.start_element(
73 'id': f'anchor-{fn_no}',
74 'href': f'annotations.xhtml#annotation-{fn_no}',
77 builder.start_element('sup', {})
78 builder.push_text(str(fn_no))
83 builder.enter_fragment('footnotes')
84 builder.start_element('div', {
85 'id': f'annotation-{fn_no}',
88 builder.start_element('a', {
89 'href': f"part{part_number}.xhtml#anchor-{fn_no}"
91 builder.push_text(str(fn_no))
93 builder.push_text('. ')
95 super().epub_build(builder)
96 builder.push_text(' [' + self.qualifier + ']')
99 builder.push_text('\n')
101 builder.exit_fragment()
106 """Przypis autorski."""
110 return _("author's footnote")
114 """Przypis tłumacza."""
118 return _("translator's footnote")
122 """Przypis redakcyjny."""
126 return _("editor's footnote")
130 """Przypis redakcji źródła."""
134 return _("source editor's footnote")