Repository navigation
feat(reader): group chapters under collapsible parts in the HTML book's TOC - #20
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19.
The reader's table of contents was a flat list, so a part divider (
# Title {.part}) looked like one more chapter and a book with many parts had an index that was hard to scan.Changes
book.py: a TOC entry from a part heading carries"part": true; order is unchanged.toc_part_css()copies thecontentof the theme's lasth1.part::beforerule (after user CSS) into a TOC label rule counted with its ownpartcounter, so the label reads «Part I», «Parte I» or whatever the theme says. A theme that does not number parts gets no label.reader.js: each part becomes a<li class="toc-part"><details><summary>with the chapters up to the next part nested in an<ol>. Chapters before the first part stay at the top level. All parts start collapsed; when the current chapter moves into another part, that part opens and the others close. Parts the reader opens by hand stay open until then..hereon chapter links is unchanged.<summary>gives keyboard access (Tab, Enter/Space).reader.css: part rows in the accent colour, a small uppercase label, a small-caps bold title, more space above, a chevron that turns when open, and nested chapters indented.know-how/the-html-book.md.A book without parts renders the same markup as before. Its
book.cssgains the label rule when its theme numbers parts, which matches nothing.The summary of a part toggles its group and does not jump to the part's divider page. That page is still one page before the part's first chapter.
Tests
uv run pytest: 352 passed, browser tests included. In one earlier full run,test_a_hash_opens_at_its_targettimed out once. It passed alone, in its file (20/20) and in the next full run.PARTE I … PARTE Xrows, Enter on a summary opens it, following a chapter in part III leaves only part III open with that chapter highlighted. The example book's TOC is still the flat three-chapter list.🤖 Generated with Claude Code