@@ -16,9 +16,7 @@ class RichTextBlockWithFootnotes(RichTextBlock):
16
16
final template context.
17
17
"""
18
18
19
- def render_basic (self , value , context = None ):
20
- html = super ().render_basic (value , context )
21
-
19
+ def replace_footnote_tags (self , html , context = None ):
22
20
def replace_tag (match ):
23
21
try :
24
22
index = self .process_footnote (match .group (1 ), context ["page" ])
@@ -28,6 +26,18 @@ def replace_tag(match):
28
26
return f'<a href="#footnote-{ index } " id="footnote-source-{ index } "><sup>[{ index } ]</sup></a>'
29
27
return mark_safe (FIND_FOOTNOTE_TAG .sub (replace_tag , html ))
30
28
29
+ def render (self , value , context = None ):
30
+ if not self .get_template (context = context ):
31
+ return self .render_basic (value , context = context )
32
+
33
+ html = super ().render (value , context = context )
34
+ return self .replace_footnote_tags (html , context = context )
35
+
36
+ def render_basic (self , value , context = None ):
37
+ html = super ().render_basic (value , context )
38
+
39
+ return self .replace_footnote_tags (html , context = context )
40
+
31
41
def process_footnote (self , footnote_id , page ):
32
42
footnotes = self .get_footnotes (page )
33
43
footnote = page .footnotes .get (uuid = footnote_id )
0 commit comments