From 8de6af98147d1551b7b0510a9a40d3de2523c17d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Apr 2022 13:06:42 +0530 Subject: [PATCH] Dont break footnotes when there is an anchor in the first block level child of the note. See #1969608 (Footnote's pop-up is empty.) --- src/pyj/read_book/footnotes.pyj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pyj/read_book/footnotes.pyj b/src/pyj/read_book/footnotes.pyj index 78995c3e73..968d0c2e23 100644 --- a/src/pyj/read_book/footnotes.pyj +++ b/src/pyj/read_book/footnotes.pyj @@ -141,6 +141,11 @@ def unhide_tree(elem): ok_list_types = {'disc': True, 'circle': True, 'square': True} +def is_new_footnote_start(elem, start_elem): + c = get_note_container(elem) + return c is not start_elem and c is not start_elem.firstElementChild + + def show_footnote(target, known_anchors): if not target: return @@ -163,7 +168,7 @@ def show_footnote(target, known_anchors): for elem in document.documentElement.getElementsByTagName('*'): if found_note_start: eid = elem.getAttribute('id') - if eid is not target and known_anchors[eid] and get_note_container(elem) is not start_elem: + if eid is not target and known_anchors[eid] and is_new_footnote_start(elem, start_elem): # console.log('Breaking footnote on anchor: ' + elem.getAttribute('id')) v'delete get_note_container(elem).do_not_hide' break