X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/0604bdd5f693da9f1c78f9d9fa2276f0c7b6c17b..deca3e31b94bc7ec95d47c309ff560a097337e97:/src/librarian/elements/footnotes/__init__.py diff --git a/src/librarian/elements/footnotes/__init__.py b/src/librarian/elements/footnotes/__init__.py index eefe9db..d0a0bf1 100644 --- a/src/librarian/elements/footnotes/__init__.py +++ b/src/librarian/elements/footnotes/__init__.py @@ -5,3 +5,75 @@ class Footnote(WLElement): def txt_build(self, builder): pass + def html_build(self, builder): + if not builder.with_footnotes: + return + + builder.footnote_counter += 1 + fn_no = builder.footnote_counter + footnote_id = 'footnote-idm{}'.format(self.attrib['_compat_ordered_id']) + anchor_id = 'anchor-idm{}'.format(self.attrib['_compat_ordered_id']) + + # Add anchor. + builder.start_element( + 'a', + { + "href": '#{}'.format(footnote_id), + "class": "annotation-anchor", + "id": anchor_id, + } + ) + builder.push_text('[{}]'.format(fn_no)) + builder.end_element() + + # Add actual footnote. + builder.enter_fragment('footnotes') + builder.start_element('div', {'class': 'fn-{}'.format(self.tag)}) + builder.push_text('\n') # Compat + builder.start_element('a', {'name': footnote_id}) + builder.end_element() + builder.start_element('a', { + 'href': '#{}'.format(anchor_id), 'class': 'annotation' + }) + builder.push_text('[{}]'.format(fn_no)) + builder.end_element() + + builder.start_element('p') + super(Footnote, self).html_build(builder) + + builder.push_text(' [{}]'.format(self.qualifier)) + builder.end_element() + builder.end_element() + builder.exit_fragment() + + +class PA(Footnote): + """Przypis autorski.""" + @property + def qualifier(self): + _ = self.gettext + return _("author's footnote") + + +class PT(Footnote): + """Przypis tłumacza.""" + @property + def qualifier(self): + _ = self.gettext + return _("translator's footnote") + + +class PR(Footnote): + """Przypis redakcyjny.""" + @property + def qualifier(self): + _ = self.gettext + return _("editor's footnote") + + +class PE(Footnote): + """Przypis redakcji źródła.""" + @property + def qualifier(self): + _ = self.gettext + return _("source editor's footnote")