section ticking covers the section

This commit is contained in:
2026-08-27 15:43:00 -04:00
parent 6dcff467d7
commit 8e02235a71
4 changed files with 97 additions and 12 deletions

View File

@@ -212,3 +212,14 @@ def test_an_empty_document_produces_a_named_guide_and_no_blocks():
parsed = parse('')
assert parsed['title'] == 'Untitled'
assert parsed['blocks'] == []
def test_a_heading_carries_its_rank():
"""Ticking a section off has to cross out what belongs to it, and nothing
records that a sub-heading belongs to the heading above unless the level
travels with them."""
parsed = parse('<h1>T</h1><h2>Credentials</h2><p>Intro.</p>'
'<h3>SFLD share</h3><p>Detail.</p><h2>Next</h2>')
headings = [(b['text'], b.get('level'))
for b in parsed['blocks'] if b['type'] == 'heading']
assert headings == [('Credentials', 2), ('SFLD share', 3), ('Next', 2)]