X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/d26d6a7fdcb2c6e26fd097532765b62fd17b429c..9c9a55d7dda5595a236f11977d7f21f804d37872:/src/librarian/elements/footnotes/__init__.py?ds=sidebyside diff --git a/src/librarian/elements/footnotes/__init__.py b/src/librarian/elements/footnotes/__init__.py index d0a0bf1..76be8e8 100644 --- a/src/librarian/elements/footnotes/__init__.py +++ b/src/librarian/elements/footnotes/__init__.py @@ -1,7 +1,20 @@ +# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. +# from ..base import WLElement class Footnote(WLElement): + NO_TOC = True + START_INLINE = True + ASIDE = True + + def signal(self, signal): + if signal == 'INLINE': + self.START_INLINE = False + else: + super().signal(signal) + def txt_build(self, builder): pass @@ -46,6 +59,49 @@ class Footnote(WLElement): builder.end_element() builder.exit_fragment() + def epub_build(self, builder): + fn_no = builder.assign_footnote_number() + part_number = getattr( + builder, + 'chunk_counter', + 1 + ) + + builder.start_element( + 'a', + { + 'class': 'anchor', + 'id': f'anchor-{fn_no}', + 'href': f'annotations.xhtml#annotation-{fn_no}', + } + ) + builder.start_element('sup', {}) + builder.push_text(str(fn_no)) + builder.end_element() + builder.end_element() + + + builder.enter_fragment('footnotes') + builder.start_element('div', { + 'id': f'annotation-{fn_no}', + 'class': "annotation" + }) + builder.start_element('a', { + 'href': f"part{part_number}.xhtml#anchor-{fn_no}" + }) + builder.push_text(str(fn_no)) + builder.end_element() + builder.push_text('. ') + + super().epub_build(builder) + builder.push_text(' [' + self.qualifier + ']') + builder.end_element() + + builder.push_text('\n') + + builder.exit_fragment() + + class PA(Footnote): """Przypis autorski."""