Also create a page list anchor map in the book metadata

This commit is contained in:
Kovid Goyal 2024-08-20 08:18:34 +05:30
parent a5086d836b
commit 76743a0210
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -193,6 +193,18 @@ def toc_anchor_map(toc):
return dict(ans)
def pagelist_anchor_map(page_list):
ans = defaultdict(list)
seen_map = defaultdict(set)
for x in page_list:
name = x['dest']
frag = x['frag']
if name and frag not in seen_map[name]:
ans[name].append({'frag':frag})
seen_map[name].add(frag)
return dict(ans)
class SimpleContainer(ContainerBase):
tweak_mode = True
@ -749,6 +761,7 @@ def process_exploded_book(
'link_to_map': {},
'page_progression_direction': page_progression_direction,
'page_list': page_list,
'pagelist_anchor_map': pagelist_anchor_map(page_list),
}
names = sorted(