guest role; guide section ticking
This commit is contained in:
@@ -124,11 +124,21 @@ def plaintext(blocks):
|
||||
|
||||
|
||||
def checklistitemcount(blocks):
|
||||
"""How many tickable items a guide has, for the list and the progress bar."""
|
||||
"""How many tickable things a guide has, for the card and the progress bar.
|
||||
|
||||
Checklist items, plus the sections a reader crosses off to keep their place:
|
||||
a step, or a heading. A guide converted from an article often has fifty
|
||||
headings and no steps at all, and "0 steps to tick" on a card that is
|
||||
entirely tickable reads as a broken feature.
|
||||
"""
|
||||
total = 0
|
||||
for block in blocks or []:
|
||||
if isinstance(block, dict) and block.get('type') == 'checklist':
|
||||
if not isinstance(block, dict):
|
||||
continue
|
||||
if block.get('type') == 'checklist':
|
||||
total += len(block.get('items') or [])
|
||||
elif block.get('type') in ('step', 'heading'):
|
||||
total += 1
|
||||
return total
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user