mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Simplification
This commit is contained in:
parent
5357757cb1
commit
f5337dcad0
@ -127,19 +127,19 @@ def current_toc_anchor_map(tam, anchor_funcs):
|
|||||||
|
|
||||||
def update_visible_toc_anchors(toc_anchor_map, anchor_funcs):
|
def update_visible_toc_anchors(toc_anchor_map, anchor_funcs):
|
||||||
tam = current_toc_anchor_map(toc_anchor_map, anchor_funcs)
|
tam = current_toc_anchor_map(toc_anchor_map, anchor_funcs)
|
||||||
prev = before = after = None
|
before = after = None
|
||||||
visible_anchors = {}
|
visible_anchors = {}
|
||||||
has_visible = False
|
has_visible = False
|
||||||
for anchor_id in tam.pos_map:
|
for anchor_id in tam.pos_map:
|
||||||
pos = tam.pos_map[anchor_id]
|
pos = tam.pos_map[anchor_id]
|
||||||
visibility = anchor_funcs.visibility(pos)
|
visibility = anchor_funcs.visibility(pos)
|
||||||
if visibility is 0:
|
if visibility < 0:
|
||||||
before = prev
|
before = anchor_id
|
||||||
|
elif visibility is 0:
|
||||||
has_visible = True
|
has_visible = True
|
||||||
visible_anchors[anchor_id] = True
|
visible_anchors[anchor_id] = True
|
||||||
elif visibility > 0:
|
elif visibility > 0:
|
||||||
after = anchor_id
|
after = anchor_id
|
||||||
break
|
break
|
||||||
prev = anchor_id
|
|
||||||
|
|
||||||
return {'visible_anchors':visible_anchors, 'has_visible':has_visible, 'before':before, 'after':after}
|
return {'visible_anchors':visible_anchors, 'has_visible':has_visible, 'before':before, 'after':after}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user